开发者

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:

  1. You should probably be using .val() to get the values of the inputs
  2. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜