I have a HTML div (f
) with input
s in, and I would like it to be that when the input is clicked off, it changes to the bad_input
class that I have specified (background color is red). However, this does not work and I am unsure of how to fix it. The inputs have placeholder
tags, however, I am sure this is not the reason why it is not working.
$("#f input").blur(function()
{
if (!$(this).val())
{
$(this).attr('class', 'bad_input');
}
});
User .addClass()
jquery method to add the class, not attr()
What you are doing will add a attribute with class = "bad_input"
in the input
$("#f input").blur(function()
{
if (!$(this).val())
{
$(this).addClass('bad_input');
}
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments