2
我想解析一个简单的XML文档与jQuery。有谁知道为什么在Chrome和Firefox中以下工作正常,但不在Internet Explorer(7和8)中?Internet Explorer的jQuery的:包含问题
var selBunit = $("#bunit").val();
$(bunitXml).find('bunit bname:contains('+selBunit+')').parent().find('team')
下面是xml的片段。所以基本上我试图返回所选业务单元(“bunit”)的所有“团队”元素。
<bunit>
<bname>Unit 1</bname>
<teams>
<team>
<name>Team 1</name>
<jobtitles>
<jobtitle approval="false">Jobtitle 1</jobtitle>
</jobtitles>
</team>
<team>
<name>Team 2</name>
<jobtitles>
<jobtitle approval="false">Jobtitle 2</jobtitle>
</jobtitles>
</team>
</teams>
</bunit>
一开始我尝试
$(bunitXml).find('bunit bname:contains($("#bunit").val())').parent().find('team')
不工作在所有。一些谷歌搜索后,我尝试了以下内容:
var selBunit = $("#bunit").val();
$(bunitXml).find('bunit bname:contains('+selBunit+')').parent().find('team')
它在Chrome和Firefox中返回所有团队元素,但不在Internet Explorer中。我无法理解它。我对jQuery相当陌生,所以我可能会完全错误,所以任何建议,将不胜感激。多谢