Membuat Input dengan Double Click

// On double click show the input box
$( "#text1" ).dblclick(function() {

  $( "#text1" ).hide();
  $( "#text1_input" ).val($( "#text1" ).html()); // Copies the text of the span to the input box.
  $( "#text1_input" ).show();
  $( "#text1_input" ).focus();
  
});

// What to do when user changes the text of the input
function textChanged(){

  $( "#text1_input" ).hide();
  $( "#text1" ).html($( "#text1_input" ).val()); // Copies the text of the input box to the span.
  $( "#text1" ).show();
      
  // Here update the database
      
}

// On blur and on enter pressed, call the textChanged function
$( "#text1_input" ).blur(textChanged);
$( "#text1_input" ).keypress(function (e) {
 var key = e.which;
 if(key == 13)  // the enter key code
  {
    textChanged();
    return false;  
  }
});
About Reza Ervani 430 Articles
Adalah pendiri programming.rezaervani.com -

Be the first to comment

Leave a Reply

Your email address will not be published.


*


This site uses Akismet to reduce spam. Learn how your comment data is processed.