Table Row Traversing with JavaScript jQuery -



Table Row Traversing with JavaScript jQuery -

i have table formatted following:

<table> <tbody> <tr class="node"> <td onclick='toggledesc(this.parentnode);'>blah</td> </tr> <tr class="subnode"> <td>sblah</td> </tr> <tr class="subnode"> <td>sblah</td> </tr> <tr class="subnode"> <td>sblah</td> </tr> <tr class="node"> <td onclick='toggledesc(this.parentnode);'>blah</td> </tr> <tr class="subnode"> <td>sblah</td> </tr> <tr class="subnode"> <td>sblah</td> </tr> </tbody> </table>

i have function toggles display of .subnode classes based on td of .node above it. function looks this:

function toggledesc(item) { var descrow = item.nextelementsibling; $(descrow).toggleclass("descdisplay"); }

however, function above toggles display of first .subnode encounters. know how .toggleclass each .subnode after .node until next .node hit?

use nextuntil():

$(item).nextuntil('tr.node').toggleclass("descdisplay");

see documentation

javascript jquery html

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -