How to know how many of a particular kind of element exist in the current web page in Jquery?

StackOverflow https://stackoverflow.com/questions/1811867

  •  06-07-2019
  •  | 
  •  

Question

There are many <label name="delQ" style="cursor:pointer">Remove</label> elements in a web page; the elements are dynamically created. How to determine how many "delQ" exist in the current web page?

$('[name="delQ"]').live('click', function() {
//Get the number of name="delQ" in the current web page.
});

How to do it in Jquery?

Was it helpful?

Solution

$('label[name="delQ"]').length;

length

Returns the number of elements in the jQuery object.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top