I have a wrapper element, which contains child elements with unique is's. How does one get the an element without having to traverse?
eg.
<div id="wrapper">
<div id="child1">content</div>
<div id="child2">content</div>
<div id="child3">content</div>
</div>
I am currently using a jQuery.find, but still unable to find only one and first element.
$("#wrapper").find("#child1")......
The code above is not returning the child element specified inside the find function parameter but an array, containing only child1. Thus resulting to write code like this.
$("#wrapper").find("#child1").each(function(){//do something...});
PS: I would really like to avoid something like this as it is inefficient
$("#wrapper #child1")
As I have the #wrapper element already and do not want to traverse over the entire DOM once again.