jQuery event binding does not work properly or i can't make it properly working
Posted
by Saiful
on Stack Overflow
See other posts from Stack Overflow
or by Saiful
Published on 2010-05-21T05:35:00Z
Indexed on
2010/05/21
5:40 UTC
Read the original article
Hit count: 217
HTML:
<input id="email" name="email" type=text />
<input id="password name="password" type="password" />
JavaScript:
var fields = ["email","password"];
for (var i in fields) {
var field = $("#"+fields[i]);
field.bind({
focus: function() {
field.css("border-color","#f00");
},
blur: function() {
field.css("border-color","#000");
}
});
}
My desire action will be as follows:
- When I place cursor on any of the above fields the input field's border will be red.
- When I take away the cursor from the field it's border will be black.
But the event is occurs only for the password filed whether I place and take away cursor form any of the above fields.
© Stack Overflow or respective owner