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?
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?
With jQuery
you can use
$('#main-div .specific-class').length
otherwise in VanillaJS (from IE8
included) you may use
document.querySelectorAll('#main-div .specific-class').length;