2
我有一個XML文件是這樣的:當從XML提取值,文本框不採取雙空格
<Product ID="1" Code="AAAA AA" Price="10"/>
<Product ID="2" Code="AAAA AA" Price="20"/>
我加載「代碼」爲標籤
$('#select1').append($('<option></option>').val('1').html($(this).attr('Code')));
,我比較值SELECT1和從XML路徑值:
function()
{
var e = document.getElementById('textbox1');
var proValue= e.options[e.selectedIndex].text;
if($(this).attr('Code')==proValue)
{
var proPrice = $(this).attr('Price');
document.getElementById('textfbox2').value=proPrice;
}
}
的問題是,$(this).attr('Code')==proValue
返回與ID =「2」 false作爲它的值有兩個空間。 但是,它與ID ='1'的工作正常。
任何想法,我該如何解決它?
出於好奇...爲什麼它有雙重空間? –