我想在用戶更改選定的值後執行某些操作,使用此代碼我只需要 想要從所選值中獲取值,而不是兩者。如何使用jQuery觸發特定選擇框更改?
到目前爲止,我有這樣的:
Issiue的代碼是隻有第一個觸發器。
<div class="colname">
<label for="input">Input</label>
<select name="input" class="input">
<option>Test1</option>
<option>Test2</option>
</select>
</div>
<div class="colname">
<label for="kostnad">Input</label>
<select name="input" class="input">
<option>Test1</option>
<option>Test2</option>
</select>
</div>
<script>
$('.input').change(function(){
var ok = $(this).val();
if(ok == 1)
// do that and this
});
</script>
使用'$(本).VAL()'內'更改'select'的事件處理程序。 – Tushar
TypeError:elem.nodeName未定義 – sdfgg45