Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Traversing an unordered list using jQuery

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.

like image 304
MegaMatt Avatar asked Dec 01 '22 11:12

MegaMatt


1 Answers

You could use each() for this.

E.g.

$('ul#id li').each(function(index, element) {
    var li = $(element);
    // ...
});
like image 108
BalusC Avatar answered Dec 05 '22 13:12

BalusC