Due to lack of placeholder support in Internet Explorer for input elements, I am attempting to implement a workaround using jQuery.
My goal is to have the field value initialized on page load. While I have successfully achieved this on field focus, I'm struggling to make it work upon page load. For example, the following code works:
// This Works on focus, "Email" is shown in text box
$(function() {
$("#login_email").focus(function()
{
if ($(this).val() == "")
{
$(this).val("Email");
}
});
});
// Even though I expected this to initialize on page load, it does not work ???
// This does not work
$(function() {
$("#login_email").val("Email");
});
How can I resolve this issue?
What is the reason behind option two not working while option one does? What sets them apart??