Count Div Elements With The Same Id Jquery
Solution 1:
Give class name for div and paste the below code.. It will give the count.
var conveniancecount = $("div[class*='conveniancecount']").length;
Solution 2:
Having same id multiple times is not recommended by W3C. See what they say about it.
The id attribute specifies a unique id for an HTML element (the id attribute value must be unique within the HTML document). The id attribute can be used to point to a style in a style sheet. The id attribute can also be used by a JavaScript (via the HTML DOM) to make changes to the HTML element with the specific id.
Suggestion:
Use class name for all the divs you want to group and use this selector:
$('.myClassName')
See these references for more:
Solution 3:
Maybe this can be useful for you:
- How Can I Fade Are Background Image In And Out Using Jquery In A Parent Div Without Having It Affect The Child Div?
- Sorting Table Rows According To Table Header Column Using Javascript Or Jquery
- Custom File Input Using Jquery Restrict The User File Types And Filename If The User Click Check Box It Input File Disable
I've been making inner ajax calls wich may be the container starts wrapping inside one time and another in some cases. I resolve it with this:
jQuery("div[id='yourWrapper_1']").length
Try unwrapping it, because you shouldn't have repeated ID's on your DOM
Hope it helps you
Regards!
Post a Comment for "Count Div Elements With The Same Id Jquery"