how can i count the total number of divs with same name.......i.e.
suppose i have 3 divs with same name than how can i count these three divs with jquery.
how can i count the total number of divs with same name.......i.e.
suppose i have 3 divs with same name than how can i count these three divs with jquery.
Very easy +)
$('div').size()
Or specify any additional selector parameters.
Like this:
var cnt = $('div[name=asfd]').length;
However, the name property is not a standard attribute for the div element.
If you are looking for a text inside the div elements:
var cnt = $('div').filter(function(){
return $(this).text() == 'John Doe'
}).length;
You can do any comparison you like in the filter. Note that this will check all div elements in the document, so you should try to limit the number of elements in the first expression if possible.