I was wondering if some jQuery expert would be so kind to convert the below script to jQuery. I am having trouble converting it myself and would much prefer to use a jQuery equivalent.
What I am trying to do is simply remove the default value of ‘Search’ from a keyword field onSubmit, as the user can leave the keyword field blank.
function clearValue() {
var searchValue = document.getElementById("global-search").value;
if (searchValue == "Search") {
document.getElementById("global-search").value = "";
}
}
Any help would be much appreciate.
Note that
.on()is new in jQuery 1.7 and in this case is the same as.bind().Here is the documentation related to this answer:
.on(): http://api.jquery.com/on.val(): http://api.jquery.com/valdocument.ready: http://api.jquery.com/ready/