有人可以帮我吗,为什么没有检测到更改
这是我的单选按钮表单 -
<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/