Posted by & filed under Javascript/YUI/jQuery.

For some reason IE 7 and earlier versions choke on references such as or $( As a workaround, as awkward as this is, you can make call $($(, which seems to work in all browsers. Awkward, ugly, unexplainable (at least to my feeble mind), but it works… I came across this solution here.

  • Chris

    Weird. I get the part where IE doesn’t automatically extend DOM nodes with Prototype features, but not the part where fails… What is obj here? what happens if you call someNode.parentNode.getAttribute(‘id’) ? I would really surprised if these standard DOM methods fail. But alas there’s IE for you.

  • joe

    “obj” is the reference to the DOM node, such as the iterator of a Prototype “each” loop. I admit to not playing around with all of the different above combinations in all the different versions of IE, but suffice to say, IE chokes on at least some of these in an unexpected fashion!

  • Chris

    Prototype follows the Ruby logic of trying to mix new methods into existing classes. While this can work well for some objects (Array, Number) for DOM nodes this causes problems since attributes on DOM nodes affect the layout of the page and for an older browser not anticipating this kind of monkeywrenching, it will choke. Though I love the dynamic quality of Ruby classes, for work in current browsers I think that libraries that have their own NodeInstance classes without affecting the existing HTMLNode class are a bit more reliable (YUI and JQuery)