I have a main div in my page with a specific id. Now some input elements of the same class are present in this div. So how can I count the number of these elements of same class in this div using jQuery?
id
div
With jQuery you can use
jQuery
$('#main-div .specific-class').length
otherwise in VanillaJS (from IE8 included) you may use
IE8
document.querySelectorAll('#main-div .specific-class').length;
1.4m articles
1.4m replys
5 comments
57.0k users