Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/275.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 使用javascript显示标签中下拉列表的选择_C#_Javascript_Asp.net Mvc_Label - Fatal编程技术网

C# 使用javascript显示标签中下拉列表的选择

C# 使用javascript显示标签中下拉列表的选择,c#,javascript,asp.net-mvc,label,C#,Javascript,Asp.net Mvc,Label,我有一个下拉列表,我希望当我的文档加载时,下拉列表中当前选择的值会出现在标签中 我有一个剧本 var x = document.getElementById('vatRate'); document.getElementById('pricingConsumerVat').textContent = x; 我在变量x中获得值,但是我无法在标签中显示相同的值 为什么会这样 我的标签是 <label id="pricingConsumerVat"></la

我有一个下拉列表,我希望当我的文档加载时,下拉列表中当前选择的值会出现在标签中

我有一个剧本

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

    document.getElementById('pricingConsumerVat').textContent = x; 
我在变量x中获得值,但是我无法在标签中显示相同的值

为什么会这样

我的标签是

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

任何jQuery解决方案都是最受欢迎的。

试试这个

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


您的
x
HTMLinputObject
您需要设置
x.value
document.getElementById('pricingConsumerVat').innerHTML = x.value;
var x  = document.getElementById('vatRate'); 

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