Skip to content

Instantly share code, notes, and snippets.

@liliumbs
Created February 3, 2012 08:02
Show Gist options
  • Save liliumbs/1728865 to your computer and use it in GitHub Desktop.
Save liliumbs/1728865 to your computer and use it in GitHub Desktop.
Google Like Search Form - JavaScript
$(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