JavaScript read radio button value in IE and FireFox

前端 未结 5 847
眼角桃花
眼角桃花 2021-01-21 05:02

I have a simple web form that uses JavaScript for building a POST statement. In Chrome, I can use a simple line of code...

var form = document.forms[\'myForm\'];         


        
5条回答
  •  天涯浪人
    2021-01-21 05:22

    You can try this:

    var form = document.querySelector('form#myForm');
    var env_value = form.querySelector('[name="env"]:checked').value;
    

提交回复
热议问题