get value of hidden field

2019-02-16 10:43发布

I reference the hidden field like:

var h = document.getElementById('myHiddenField');

How can I set the value to 100, and then output the value using a simple alert();?

4条回答
放我归山
2楼-- · 2019-02-16 11:01
//get value
var hidderValue = document.getElementById('myHiddenField').value;

//set value
document.getElementById('myHiddenField').value = 200;
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-02-16 11:03

The value property of the element.

查看更多
神经病院院长
4楼-- · 2019-02-16 11:04
var h = document.getElementById('myHiddenField');
h.value = 100;
alert(h.value);
查看更多
啃猪蹄的小仙女
5楼-- · 2019-02-16 11:15

Maybe you want to set hidden field's value IN the html part. To do so write:

<input type="hidden" id="myHiddenField" value="100"></input>
查看更多
登录 后发表回答