March 29, 2012
first child in jquery
Question by Chapsterj
HTML:
<div class="wrapper" style="display:none">
<div class="panel"></div>
</div>
JS CALL
var element = $(".wrapper");
element.toggle().children(":first").custom();
$(".wrapper .panel").custom();
CUSTOM JQUERY METHOD
$.fn.custom = function() {
return this.each(function() {
console.log(" this = ", this);
// do something to each dom element.
});
};
Whats odd here is when I do a console.log in IE its showing the first call to the panel element as a
[object HTMLGenericElement]
but the second call shows it as a [objectHTMLDIVElement]
Why is this and how to have the first call be a [objectHTMLDIVElement]