Learn free online HTML5, javascript, and jquery Tutorials by Examples

Tuesday, 17 June 2014

Clear input on focus with jQuery and return on blur

----------------------------------------------
<script src="http://http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>   
<input id="txt2" value="enter text" />

<script>
      $(window).load(function () {
       $('#txt2').val('Search');
            $('#txt2').bind('blur',function() {
                $(this).val('Search');
      });
      $('#txt2').bind('focus',function() {
                $(this).val('');
      });
      });
</script>
----------------------------------------------

No comments:

Post a Comment