How to remove default value of input on focus
问题 I have an input box that has default value text assigned to it. How can I remove this text when the user focuses on the field:: CoDE <input type="text" name="kp1_description" value="Enter Keypress Description"> 回答1: $(document).ready(function(){ var Input = $('input[name=kp1_description]'); var default_value = Input.val(); Input.focus(function() { if(Input.val() == default_value) Input.val(""); }).blur(function(){ if(Input.val().length == 0) Input.val(default_value); }); }) That should do it