I want to check the type of an element which is placed inside a div. I’m not able to reference the child element. I have tried using the following:
$("#"+styleTarget).siblings(0).get(0)tagName
Where styleTarget is a variable holding the id of the parent div.
There’s difference between a child and a sibling. In the example below, all the
<li>are childrens of<ul>. Each<li>is a sibling of all of the other<li>elements, because they are on the same level in the DOM tree.You should be using
.children(), as documented here http://api.jquery.com/children/.