Search code examples
javascriptjquerylive

problem with Jquery LIVE with $(this)


I have a problem, I'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?


Solution

  • 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?