I have a bunch of elements with <div id='id1'></div> and would like to return the quantity/count of them.
I am using the following code, but it always returns the value of 1:
alert( $('#id1').size() );
What am I doing wrong?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I figured out my own answer. I should have done:
I just needed it to return a value greater than 1, and this does the trick.
I know I should be using class instead of id, but in my program, class is already used for something specific and I do another action based on the class which can’t have multiple class names, but that’s another story, and outside the scope of this topic. Thanks to everyone who chimed in though.