views:

197

answers:

3

Hello all,
Here is my code:

$(document).ready(function(){  
    $('.classOne').mouseover(function(e) {  
        alert($(e).attr('id'));  
    });  
});  

Now, I know that something is actually wrong with my code, what will be correct in order to get the result with the ID of the current asp:LinkButton that I hovered in the alert() message?
Thanks for all helpers!

+2  A: 

You should do this instead:

$(document).ready(function(){
   $('.classOne').mouseover(function() {
      alert($(this).attr('id'));
   });
});
ryanulit
+2  A: 

e is your event, not your element. Your element is wrapped in this function.


$(document).ready(function() {
    $('.classOne').mouseover(function(e) {
        alert($(this).attr('id'));
    });
});
mike clagg
A: 

Couple of assumptions:

  • The link button is rendered with the valid class 'classOne'
  • The button is not added to the page collection via an AJAX callback
  • the 'e' parameter actualy is an object of the event & not really the object of the HTML element

    (document).ready(function(){
    $('.classOne').bind('mouseover', function(){
    alert($(this).attr('id'));
    });
    });

Sunny