ドロップダウンでアイテムが選択されているときに、送信ボタンを有効にしようとしています。 ここにコードがあります。ユーザーがドロップダウンから2つのボタンを有効にする必要がある場合は、2つのボタンがあります。それ以外の場合は、項目がドロップダウンから選択されるまで、消えなければなりません。任意のjqueryプラグインを追加する必要があるかどうかjqueryでドロップダウンアイテムが選択されるまでボタンを無効にする
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/jquery-ui.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$(".nextbutton").attr("disabled", true);
$(".nextbutton1").attr("disabled", true);
$('.dropdown').change(function() {
if ($('.dropdown').val() == 0) {
$(".nextbutton").attr("disabled", true);
$(".nextbutton1").attr("disabled", true);
} else {
$(".nextbutton").attr("disabled", false);
$(".nextbutton1").attr("disabled", false);
}
});
});</script>
</head>
<body>
<form id="phonetypeform">
<select name="porting-p1" class="dropdown">
<option value="" class="disablenext">Please select an option...</option>
<option value="1" class="enablenext">I want to keep my current phone number</option>
<option value="2" class="enablenext">I want to choose a new number</option>
</select>
</form>
<button class="nextbutton1">sd Step</button>
<button class="nextbutton">Next Step</button>
私は上記のスニペットがうまくいきます。私は同じコードを貼り付けてコピー..それは働いていません.. – user6582683
編集、それはjqueryから取得できませんでした://code.jquery.com/jquery-1.11.3.min.js....i https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.jsを変更してStackOverflowからテストしたところ、もう一度やり直してください – Mosd