Where do I put this JS code to make it work?
listed in answer
ANSWER:
Your problem is that you’re trying to attach an event handler to an element that doesn’t exist in the DOM. in jsFiddle, by default the code runs after onload meaning the DOM + images are fully loaded.
Wrap the code in the DOM ready event:
$(function()
$("tr.clickable.subheading td").click(function()
$(this).parents("tr.clickable.subheading").nextUntil("tr.clickable.subheading").toggle();
);
});
Updated Fiddle​
or put the code in the end of the tag, like with this Fiddle.
But the first option is considered to be a better practice.

New Comments