Browsers do not recognize blur/focus in this code block
The items used in this code are loaded via AJAX. That is why I am using live()
.
But blur/focus are not recognized. Click()
is but not blur/focus.
I am using FF.
The code:
$(".card_signup_form input").live('focus', function(){
$(this).css("color","#666666");
$old_value = $(this).attr("value");
$(this).attr("value", "");
})
开发者_运维技巧.live('blur', function(){
if ($(this).attr("value") == "" ) {
alert($old_value);
};
});
A few things:
- You should probably be using .val() to get the values of the inputs
- It might be a better idea to store the old value as data in the DOM. http://api.jquery.com/jQuery.data/
Have you tried looking at the debug console in Firefox to see if your code is throwing any errors? Hit Ctrl+Shift+J to bring it up.
精彩评论