show hide - jquery collapse using image as trigger -
i have simple jquery collapsible table, header row trigger toggle data want show/hide.
what i'm after have image within header row , use trigger, rather row itself.
here example: http://jsfiddle.net/rdybt/
<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type='text/javascript'> $(document).ready(function() { $('#trigger_1').click(function () { $('#toggle_1', $(this).parent()).toggle(); }); $('#trigger_2').click(function () { $('#toggle_2', $(this).parent()).toggle(); }); }); </script> </head> <body> <img src="http://cdn5.iconfinder.com/data/icons/super-mono-reflection/blue/toggle-expand_blue.png" id="trigger_1"/> <table border="2" cellpadding="2" cellspacing="2"> <tr> <th>header </th> </tr> <tr id="toggle_1"> <td>data</td> </tr> </table> <hr> <table border="2" cellpadding="2" cellspacing="2"> <tr> <th><img src="http://cdn5.iconfinder.com/data/icons/super-mono-reflection/blue/toggle-expand_blue.png" id="trigger_2"/></th> </tr> <tr id="toggle_2"> <td>data</td> </tr> </table> </body> </html> i've done searching i'm not sure if possible or not?
any ideas or tips great.
thanks
try :
$(document).ready(function() { $('#trigger_1').click(function () { $('#toggle_1', $(this).parent()).toggle(); }); $('#trigger_2').click(function () { $('#toggle_2').toggle(); }); });
Comments
Post a Comment