I am currently working on a table that requires an undefined number of rows, each displaying a set number of elements when clicked. I have managed to achieve this functionality for a predetermined number of elements, but I am seeking a solution to make it work dynamically.
Check out the working code on jsfiddle.net
Here is a snippet of the jQuery code I have so far:
$('.warning').on('click', function(e) {
var $ele = $(this).nextUntil('.warning').find('td > div');
$ele.slideToggle();
});
});
The goal is for each clicked row in the table to display three corresponding div elements. While I prefer a jQuery solution, I am open to vanilla JavaScript implementations as well.
UPDATE: Apologies for omitting the requirement for a sliding animation. The current toggle method does not provide the desired effect.
UPDATE2: Thank you, Terry, for the recommendation. The fiddle has been revised with the updated working code.