2014-04-21 72 views
0

我有一個下拉列表,我希望當我的文檔被加載時,當前在下拉列表中選擇的值位於標籤中。使用javascript在標籤中顯示Dropdownlist的選擇

我有一個腳本

var x = document.getElementById('vatRate'); 

    document.getElementById('pricingConsumerVat').textContent = x; 

我得到的變量x的值,但是我不能在我的標籤顯示相同。

爲什麼這麼說?

我的標籤是

<label id="pricingConsumerVat"></label> 

任何jQuery的解決方案是最受大家歡迎了。

+4

你''x'is你HTMLinputObject'需要設置'x.value' –

回答

0

試試這個..

document.getElementById('pricingConsumerVat').textContent = x.value; 

document.getElementById('pricingConsumerVat').innerHTML = x.value; 
0
var x = document.getElementById('vatRate'); 

document.getElementById('pricingConsumerVat').innerHTML = x.value; 
相關問題