문제

I have a dropdownlist and I want that when my document is loaded the value currently selected in the dropdown be in the label.

I have a script as

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

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

I get the value in the variable x, however I am not able to display the same in my label.

Why so ?

My label is as

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

Any jQuery solutions is most welcomed too.

도움이 되었습니까?

해결책

Try this..

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

or

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

다른 팁

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

document.getElementById('pricingConsumerVat').innerHTML = x.value; 
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top