jquery loop hover button

Posted by john morris on Stack Overflow See other posts from Stack Overflow or by john morris
Published on 2010-03-11T18:41:17Z Indexed on 2010/03/11 18:44 UTC
Read the original article Hit count: 168

Filed under:
|
|
|

ok i have 6 buttons, im trying to have a jquery listener for when you hover over one of the 6 buttons, it changes class. im using a for loop to do this, heres my code:

$(document).ready(function() {
for($i=1;$i<7;$i++) {
      $('#button'+i).hover(function() {
        $(this).addClass('hovering');
      }, function() {
        $(this).removeClass('normal');
      });
}  
});

each button has an id of "buttonx" ( the x being a number )

help?

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about hover