I have a large file of this form [similar div\'s throughout]. I want to be able to select a div
, find the number of ul
\'s in it and traverse through ea
Your HTML is currently incorrect, since you're simply starting new You need to select all of the Take a look at this jsFiddle demo.
elements rather than closing the existing ones. Ignoring that because it's trivial to fix, we'll move on to the real issue.
.each()
function. It might look something like this:
var experiments = $('.experiment'); // all of them
experiments.each(function(i, val) { // will iterate over that list, one at a time
var experiment = $(this); // this will be the specific div for this iteration
console.log("Experiment: " + experiment.find('.experiment-number').text());
// outputs the experiment number
console.log("Experiment ULs: " + experiment.find('ul').length);
// number of
elements in this