gpt4 book ai didi

javascript - JQuery 中未检测到单选按钮更改

转载 作者:行者123 更新时间:2023-11-28 10:48:42 25 4
gpt4 key购买 nike

有人可以帮我吗,为什么没有检测到更改

这是我的单选按钮表单 -

<form style = "padding:10px; margin:5px;" id="AskMethod">
Select Option:
<input type="radio" name="method" value ="TextMethod" checked = "checked">Type text
<input type="radio" name="method" value ="ImageMethod">Upload Image
</form>

这是我的 jquery 例程 -

$(document).ready(function() {
$('input [type=radio][name=method]').on('change', function() {
switch ($(this).val()) {
case 'TextMethod':
alert("Text");
break;
case 'ImageMethod':
alert("Image");
break;
}
});
});

最佳答案

请使用更改如下

$('form#AskMethod [type=radio][name=method]').change(function() {
switch($(this).val()) {
case 'TextMethod':
alert("Text");
break;
case 'ImageMethod':
alert("Image");
break;

});

关于javascript - JQuery 中未检测到单选按钮更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37759803/

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