How to select a single child element using jQuery?
No. Every jQuery function returns a jQuery object, and that is how it works. This is a crucial part of jQuery's magic.
If you want to access the underlying element, you have three options...
- Do not use jQuery
- Use
[0]
to reference it Extend jQuery to do what you want...
$.fn.child = function(s) { return $(this).children(s)[0]; }
I think what you want to do is this:
$(this).children('img').eq(0);
this will give you a jquery object containing the first img element, whereas
$(this).children('img')[0];
will give you the img element itself.
Maybe in this way?
$('img', this)[0]