What is the difference between find() and children() in jQuery?
<div id="d"><ul><li>A</li><li>B</li></ul></div>
console.log($('#d').children().length);
console.log($('#d').find('li').length);
Console output
1
2
Learn more about the similar topics:
| Tutorials |
|---|
| jQuery Selectors |
| jQuery Traversing: Ancestors |
| jQuery Traversing: Descendants |
| jQuery Traversing: Siblings |
| jQuery Traversing: Filtering |
| Exercises & Assignments |
|---|
| Write jQuery code to count the items of a list |
| Write jQuery code to find the total of a table column |
| Write jQuery code to add alternate row colors to a table |