This should be an easy one, but I'm not finding much online:
I have an unordered list <ul>, with a few list items underneath it <li>, and I'd like to address each one in the list, and act on it. How can I do this using jQuery?
Thanks.
You could use each() for this.
E.g.
$('ul#id li').each(function(index, element) {
var li = $(element);
// ...
});
each() - docs.jquery.com/Core/each as opposed to the utility function each() :)$('ul#id > li').each(...)Use this code and change id as appropriate.
$("ul#id_of_desired_ul > li").each(function() {
//do stuff
// $(this) references each li
});
$('ul#id > li').each(...)