I originally used JQuery for this project, but now I’m having to use Prototype, and I’d like to take what I’ve written in JQuery and use it in Prototype.
It’s a simple bit of code that empties the search bar when the user clicks on it. I’m sure it’s pretty easy to do in Prototype, but I don’t know how.
Here’s what I wrote for JQuery…
$(window).load(function(){
$("#search").on("click", function() {
if ($(this).val() == "search") {
$(this).val("");
$(this).css("color", "black");
}
});
$("#search").blur(function() {
if ($(this).val() == "") {
$(this).css("color", "gray");
$(this).val("search");
}
});
});
How can I convert the above for use with Prototype?
For anyone who wants to do this in the future, here’s what worked for me: