开发者

How do select a radio button with JavaScript?

开发者 https://www.devze.com 2023-03-28 09:15 出处:网络
I\'ve tried select(); check(); and even .selected = true; but I still haven\'t gotten around to selecting that radio button. Is there any way I can accomplish this开发者_如何学Go?You have to use the c

I've tried select(); check(); and even .selected = true; but I still haven't gotten around to selecting that radio button. Is there any way I can accomplish this开发者_如何学Go?


You have to use the checked property:

element.checked = true;

Reference: HTMLInputElement


<input type=radio id='r'>
<script>
document.getElementById('r').checked=true;
</script>

Use .checked


Maybe you could post your code and we could give you a more complete solution?

To check a radio button I'm pretty sure it's .checked = true;

0

精彩评论

暂无评论...
验证码 换一张
取 消