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相當陌生,所以我可能會完全錯誤,所以任何建議,將不勝感激。多謝