You can use .length
with just a descendant selector, like this:
var count = $("#selected li").length;
If you have to use .children()
, then it’s like this:
var count = $("#selected ul").children().length;
More Related Contents:
- .prop() vs .attr()
- jQuery document.createElement equivalent?
- How can I apply a jQuery function to all elements with the same ID?
- When should I use jQuery’s document.ready function?
- How to get a DOM Element from a jQuery selector?
- Difference between HTMLCollection, NodeLists, and arrays of objects
- How do I create a link using javascript?
- How to show Page Loading div until the page has finished loading?
- Difference between “change” and “input” event for an `input` element
- What is difference between width, innerWidth and outerWidth, height, innerHeight and outerHeight in jQuery
- jQuery DOM changes not appearing in view source
- How to bind bootstrap popover on dynamic elements
- How to find a parent with a known class in jQuery?
- How to detect when an iframe has already been loaded
- jQuery: how to change tag name?
- How can I remove all CSS classes using jQuery/JavaScript?
- Count immediate child div elements using jQuery
- Convert String to XML Document in JavaScript
- JavaScript moving element in the DOM
- Storing a variable in the JavaScript ‘window’ object is a proper way to use that object?
- How to set DOM element as first child?
- JQuery html() vs. innerHTML
- JQuery – animate moving DOM element to new parent?
- Open new window without focus on it [duplicate]
- window.getSelection return html [duplicate]
- Attaching events after DOM manipulation using JQuery ajax
- jQuery difference between :eq() and :nth-child()
- What’s the difference between a jQuery object and a DOM element? Difference between .get() and .index()?
- In web browsers, what’s the difference between onblur and onfocusout?
- Create a table in SVG