Created
February 3, 2012 08:02
-
-
Save liliumbs/1728865 to your computer and use it in GitHub Desktop.
Google Like Search Form - JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).ready(function() { | |
// if text input field value is not empty show the "X" button | |
$("#field").keyup(function() { | |
$("#x").fadeIn(); | |
if ($.trim($("#field").val()) == "") { | |
$("#x").fadeOut(); | |
} | |
}); | |
// on click of "X", delete input field value and hide "X" | |
$("#x").click(function() { | |
$("#field").val(""); | |
$(this).hide(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment