When i used blur event out of input text field, it include all page, but submit button too. So how to avoid that the blur event do not include submit button?
Here is html code:
<form>
<input type="text" value="EMAIL ADDRESS_" id="text" />
<input type="submit" val="" id="submit" />
</form>
and script:
$('form input[type!=submit]').focus(function(){
$(this).val("");
});
$('form input[type!=submit]').blur(function(){
if(this.value==""){
$(this).val("EMAIL ADDRESS_");
}
});
I take this code from my previous question, but it doesn’t work.Blur event still include submit button
I think instead of avoiding one field from the selection, you should better specify the items to be considered for selection. Otherwise if someone / you, in the futue may add a new element to the form and you may be wondering where this behaviour (of blur and focus) is coming from for the “just now added element” !
Note that you are still targeting all input fields which is of type text. So if possible try to make it more specific by applying a class name to those elements and use that as the selector. Or you may use the id of the element as well.