Creating the same event for 2 different elements in jQuery (not for each one, for both!)

Posted by danfromisrael on Stack Overflow See other posts from Stack Overflow or by danfromisrael
Published on 2010-05-23T14:47:39Z Indexed on 2010/05/23 14:50 UTC
Read the original article Hit count: 165

Filed under:
|

Hey guys, I'd like to create a toggle event for 2 different TD's in my table row. the event should show / hide the next table row.

<table>
<tr>
<td>1</td> <td>2</td> <td>3</td> <td>4</td> <td>5</td> <td class="clickable1">6</td> <td class="clickable2">7</td>
</tr>
<tr><td>this row should be toggled between show/hide once one of the clickable TDs were clicked</td></tr>
</table>

here's the code i tried to apply but it has applied each one of the classes the event:

$('.clickable1,.clickable2').toggle(function() {
            $(this).parent()
               .next('tr')
               .show();
        }, function() {
        $(this).parent()
               .next('tr')
               .hide();
        });

One more thing: i'm applying on each TR a css hover psuedo class. how can i make the two TRs to be highlighted (like hover effect on two of them) ?

Thanks in advanced!

:-Dan

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about html