开发者

problem with Jquery LIVE with $(this)

开发者 https://www.devze.com 2023-01-06 10:00 出处:网络
I have a problem, I\'开发者_JAVA百科m using .live() to bind mouseenter like this: $(\'a\').live(\'mouseenter\',function(e){

I have a problem, I'开发者_JAVA百科m using .live() to bind mouseenter like this:

$('a').live('mouseenter',function(e){
  alert($(this).attr('title'));
});

For all my links I get an alert for the first link's title, I think the problem is from $(this) but I'm not sure, can anyone help?


I don't think the code you posted is what's actually running, it works :) You can test it here: http://jsfiddle.net/YyMDg/

See what the difference is in your actual code, are you looping somewhere for example, and $(this) isn't being evaluated in the handler but somewhere outside of it?

0

精彩评论

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