I’m iterating through a DOM to change the display characteristics of different elements. I loop through the elements, and use the JQuery .height() method to get a height:
var myHeight = myJQueryElement.height();
Trouble is, when I hit a “comment” element in Firefox, I get this error:
Error: uncaught exception: [Exception… “Could not convert JavaScript argument arg 0 [nsIDOMViewCSS.getComputedStyle]” nsresult: “0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)” location: “JS frame :: http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js :: :: line 18″ data: no]
Ok, fine, I can check the nodeType, right? No, oddly, when I call:
var nt = myJQueryElement.nodeType;
the nodeType is always “undefined”. Weird, because when I click on the element in the Javascript debugger in Firebug, it show me a correct nodeType of 8.
All I want to do is check whether the element has a height > 0, and skip it otherwise.
Any clues how to do this?
You need to check the DOM node, not the jQuery object.