css:

table.menu {border-collapse:collapse;} table.menu td {border: 1px #4682B4 solid;background-color:#B0C4DE;opacity: 0.5;} 

html:

 <table class='menu' width='100px'> <tr><td><a href='#'>Link 1</a></td> <tr><td><a href='#'>Link 2</a></td> <tr><td><a href='#'>Link 3</a></td> <tr><td><a href='#'>Link 4</a></td> <tr><td><a href='#'>Link 5</a></td> <tr><td><a href='#'>Link 6</a></td> </table> 

jquery:

 $(document).ready( function () { var def = $("#menu td").css("opacity"); $("#menu td").hover( function () { $(this).stop().animate({opacity: '1'}, 200); }, function () { $(this).stop().animate({opacity: def}, 200); } ); } ); 

This code does not work. How to make a sample correctly (if td just works)? Also a question. How to make the same sample, only + sample by thead / tbody?

  • try $("#menu > td") - Specter
  • Does not work. - Ilyushka Ovchinnikov
  • Then set your td-shkam desired class and use it as a selector. - Specter

1 answer 1

Well, you do the sample by id, and the table contains a class! Those. need to

 $(".menu td") 
  • What a trite thing ... - Specter
  • oh exactly) thank you very much) - Ilyushka Ovchinnikov
  • 2
    Mark the answer as correct, that would not hang in unanswered. - metazet