gpt4 book ai didi

javascript - 选中时如何连接 radioButton ( <input type radio ../> ) 调用函数?

转载 作者:行者123 更新时间:2023-11-30 13:21:50 25 4
gpt4 key购买 nike

如何连接radioButton

<input type radio .. />

选中时调用函数?我需要在选中时记录该按钮的值。

最佳答案

正如您在 fiddle 中看到的那样

html:

<input type="radio" value="Test 1" /> Bullet 1 <br />
<input type="radio" value="Test 2" /> Bullet 2 <br />
<input type="radio" value="Test 3" /> Bullet 3 <br />
<input type="radio" value="Test 4" /> Bullet 4 <br />

js:

$(document).ready(function() {
$("input").click(function() {
if ($(this + ":checked")) {
alert($(this).val());
}
});
});​

关于javascript - 选中时如何连接 radioButton ( &lt;input type radio ../> ) 调用函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10006892/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com