我正在尝试修复此功能以在下拉列表中显示警报。我哪里错了?不出现警报。
JS:
<script type="text/javascript">
$(document).ready(function(){
$("#submit").click(function () {
$( "#species" ).change(function(){
if ( $(this).children(":selected").val() == "" ) {
alert("empty");
}
});
});
});
</script>
形式:
<form>
<label for="species" id="species">*Species:</label><br />
<select id="species" name="species" size="1">
<option value="">Please choose a species</option>
<option value="21">Chicken</option>
<option value="28">Turkey</option>
</select>
<br />
<input type="submit" id="submit" value="Validate!" />
</form>