get value of hidden field

前端 未结 4 810
挽巷
挽巷 2021-01-11 10:20

I reference the hidden field like:

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

How can I set the value to 100, and then output the

相关标签:
4条回答
  • 2021-01-11 10:26
    //get value
    var hidderValue = document.getElementById('myHiddenField').value;
    
    //set value
    document.getElementById('myHiddenField').value = 200;
    
    0 讨论(0)
  • 2021-01-11 10:34

    The value property of the element.

    0 讨论(0)
  • 2021-01-11 10:50
    var h = document.getElementById('myHiddenField');
    h.value = 100;
    alert(h.value);
    
    0 讨论(0)
  • 2021-01-11 10:50

    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>
    
    0 讨论(0)
提交回复
热议问题