jQuery event binding does not work properly or i can't make it properly working
- by Saiful
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.