jquery 1.6.1 - selecting xml
In jquery 1.4.2 i was able to select xml residing in my html page by doing the following:
var xmlSettings 开发者_如何学运维= $("#xmlSettings")[0];
this is the same as:
document.getElementById("xmlSettings"); //this still works fine
In jquery 1.6.1 xmlSettings is undefined. all i did was upgrade my jquery from 1.4.2 to 1.6.1 and now this is not working.
is there a different selection that i need to do, or do i need to add a plugin?
xml in Html page:
<xml id="xmlSettings">
<items>
<item name="Test1">Test data 1</item>
<item name="Test2">Test data 2</item>
<item name="Test3">Test data 3</item>
</items>
</xml>
thanks in advance,
[Resolved] Thanks to Felix Kling
the problem seems to be one of the following:
1) IE9 is not rendering IE8 Standards mode properly. I just recently upgraded to IE9 but my app still needs to run in IE8 Standard Mode therefore I've forced it in IIS to render in IE8 using X-UA-Compatible IE=8
2) i also updated my jquery file from 1.4.2 to 1.6.1
but it could be a combination of these things i'm not really sure anyway using normal document.getElementById("xmlSettings");
still works fine so in the mean time i'll use that but very bizarre issue. i wouldn’t be surprised if it's an IE9 issue. Or maybe i'll remain on jquery 1.4.2 for now.
This is the real reason it's not working: a regression in jQuery 1.4.2.
You probably don't need the [0] because an id is a singular value and doesn't return an object list like finding a class would.
I've answered my own question as suggested by Arend
[Resolved] Thanks to Felix Kling
the problem seems to be one of the following:
1) IE9 is not rendering IE8 Standards mode properly. I just recently upgraded to IE9 but my app still needs to run in IE8 Standard Mode therefore I've forced it in IIS to render in IE8 using X-UA-Compatible IE=8. Also another thing about X-UA-Compatible rather use IE=EmulateIE8 not IE=8. But still even when you use IE=EmulateIE8 it still does not play nicely with jquery 1.6.1. Therefore its better to use IE9 standard mode which works fine, so busy converting code to be standard be compliant anyway better in the long run.
2) i also updated my jquery file from 1.4.2 to 1.6.1
but it could be a combination of these things i'm not really sure anyway using normal document.getElementById("xmlSettings");
still works fine so in the mean time i'll use that but very bizarre issue. i wouldn’t be surprised if it's an IE9 issue. Or maybe i'll remain on jquery 1.4.2 for now.
精彩评论