javascript - jQuery Table row toggle show/hide associated with buttons -


need little jquery , html(table).

pls take @ jsfiddle page see gonna try do.
http://jsfiddle.net/nori2tae/u25ek/

each td contains value (from 01 06) , has class name related value , lists of buttons above table. when page loaded, buttons enabled means table data visible.

when click turn on/off button, want jquery observe on/off status of buttons , if status matches values of each table row, want jquery toggleslide(show/hide) table row. (sorry poor english , explanation...)

for example, if turn off button01 row1 hidden. turn button4 , button6 off, row5 hidden. , on or vice versa...

html:

<ul id="listbtns"> <li><a href="#" class="on">01</a></li> <li><a href="#" class="on">02</a></li> <li><a href="#" class="on">03</a></li> <li><a href="#" class="on">04</a></li> <li><a href="#" class="on">05</a></li> <li><a href="#" class="on">06</a></li> </ul>  <table id="tblresult"> <thead>     <tr>         <th></th>         <th>01</th>         <th>02</th>         <th>03</th>         <th>04</th>         <th>05</th>         <th>06</th>     </tr> </thead> <tbody>     <tr>         <th>row1</th>         <td class="val01">01</td>         <td></td>         <td></td>         <td></td>         <td></td>         <td></td>     </tr>     <tr>         <th>row2</th>         <td class="val01">01</td>         <td class="val02">02</td>         <td class="val03">03</td>         <td class="val04">04</td>         <td class="val05">05</td>         <td class="val06">06</td>     </tr>     <tr>         <th>row3</th>         <td class="val03">03</td>         <td class="val05">05</td>         <td class="val04">04</td>         <td></td>         <td></td>         <td></td>     </tr>     <tr>         <th>row4</th>         <td class="val02">02</td>         <td class="val04">04</td>         <td class="val05">05</td>         <td class="val06">06</td>         <td></td>         <td></td>     </tr>     <tr>         <th>row5</th>         <td class="val04">04</td>         <td class="val06">06</td>         <td></td>         <td></td>         <td></td>         <td></td>     </tr>     <tr>         <th>row6</th>         <td class="val03">03</td>         <td class="val02">02</td>         <td class="val04">04</td>         <td class="val06">06</td>         <td class="val05">05</td>         <td></td>     </tr> </tbody> </table> 

js:

$('#listbtns a').click(function() {     $(this).toggleclass('on off');     //and function continues... }); 

i kinda stack , can come poor , inefficient codes(that perhaps might not work completely...) , dont know jquery selector use. please me out.

thanx.

need 1 line --

$(function() {     $('#listbtns a').click(function() {        $(this).toggleclass('on off');                $("#tblresult tr").eq($(this).text()).toggle('on off');     }); }); 

see demo

this work long text , row number matches.


Comments

Popular posts from this blog

php - cannot display multiple markers in google maps v3 from traceroute result -

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -