gpt4 book ai didi

javascript - 单击单选按钮时下拉列表不会禁用

转载 作者:行者123 更新时间:2023-11-28 10:49:09 26 4
gpt4 key购买 nike

它应该可以工作,但不幸的是它没有。我不知道我的代码有什么问题。当我在 jsfiddle 中尝试时,它可以工作,但在我的 Notepad++ 中它不起作用。我不明白这有什么问题。

<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script type="text/javascript">

$('input:radio[name="senior"]').change(function() {
if ($(this).val()=='Yes') {
$('#seniordis').attr('disabled',false);
} else


$('#seniordis').removeAttr('disabled', true);
});
</script>



</head>



Senior :

<input name="senior" type="radio" id="Yes" value="Yes" />Yes
<input name="senior" type="radio" id="No" value="No" selected="selected" />No<br />
<select name="seniordis" id="select">
<option value="100" >100% discount</option>
<option value="50">50% discount</option>
<option value="10">10% discount</option>
</select>
</td>

最佳答案

Your problem is, senoirdis is name not a id. Your id is select.

$().ready(function()
{
$('input:radio[name="senior"]').change(function() {
if ($(this).val()=='Yes') {
$('#select').prop('disabled',false);
}
else
{
$('#select').prop('disabled',true);
}
});

});

关于javascript - 单击单选按钮时下拉列表不会禁用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36660572/

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