Wednesday 20 July 2011

Find Number of Child Elements (Length) Using jQuery

Hi Friends, Some days ago I was working on one task in which I was trying to find number of child elements by id or class of parent element by jQuery. I searched about it and found solution for it, So I thought it is worth to share on my wesbite for users, So it can be helpful for anyone and save time for someone.

So below I am going to show to show you can find number of child elements using jQuery.

$(“div#parent_div”).children().length

So by above code you can find number of child elements by id of parent element. In above code id of parent element is “parent_div” , So if you will use this code you will get number of child elements inside this parent.

So by above code you can find number of child elements by id of parent element. In above code id of parent element is “parent_div” , So if you will use this code you will get number of child elements inside this parent

No comments:

Post a Comment