Good. I think this question is too vague to get a complete answer if you think.
Where is the contents of the new columns and rows? What is your structure? What have you tried? What didn’t work? David Thomas comment.
If you do not want to use the jQuery plugin, for example this one , this means that you will need to do it yourself and a) no one here will do it for you completely b) much less, without any information that will just be guessing.
This is a quick and dirty example of what your approach should look like.
HTML
<table border="1"> <tr class="clickable"> <td colspan="2">Click to toggle Next</td> </tr> <tr> <td>Test</td> <td>Test 2</td> </tr> <tr class="clickable"> <td colspan="2">Click to toggle Next</td> </tr> <tr> <td>Test</td> <td>Test 2</td> </tr> <tr class="clickable"> <td colspan="2">Click to toggle Next</td> </tr> <tr> <td>Test</td> <td>Test 2</td> </tr> </table>
JQuery
$(".clickable").click(function() { $(this).next().toggle(); });
As I said, just an example , it does not scale (it does not even support hiding two lines), you can see here .
I can update the answer with a more personalized answer if you update your question.
But if you want to create it yourself, here are some of them that may come in handy:
. show ()
. hide ()
. toggle ()
. animate ()
: nth-child
. children ()
And many others, depending on your approach.
Good luck
source share