Search code examples
jqueryxmljquery-xml

jQuery XML parser not getting attribute 'dir'


I'm using jQuery to parse XML which is retrieved via ajax, however I have found a problem/bug with using the actual XML input.

Consider the following example:

var $line = $('<example dir="value">Example Text</example>'), dir = $line.attr("dir");
console.info("dir: ", dir);

This example should return 'value' instead it returns an empty string. Tried the above code with a different attribute name and it returns the correct value.

Is 'dir' an invalid attribute? Or is this a bug in jQuery? Just wondering...


Solution

  • dir = $line.get(0).getAttribute("dir") works just fine.

    Going to post this issue in the jQuery discussion page.