从链式下拉框的第二个框中选择一个选项时,我需要收到警报,但在选择这两个框时我会收到警报。
<select id="test" name="test">
<option value = ""> -- Select One -- </option>
<option value = "a">car</option>
<option value = "b">bike</option>
</select>
<select id="test3" name="test3" style="width:40%" onchange="alertInstitute(this)">
<option value = "aa" class = "a">bmw</option>
<option value = "ab" class = "a">audi</option>
<option value = "ba" class = "b">harley davidson</option>
<option value = "bb" class = "b">royal enfield</option>
</select>
<script>
$jq("#test3").chained("#test");
function alertInstitute(select){
alert(select.options[select.selectedIndex].text);
}
</script>
答案 0 :(得分:3)
$(function () {
$('#test3').change(function () {
alert($('#test3 option:selected').text());
});
});