我正在尝试在更改时保存选择下拉列表的表单值?
HTML
<select class="form_select" id="typeof_dwelling" name="typeof_dwelling">
<option value="-1">All </option>
<option value="APTU">Condos</option>
<option value="HOUSE">Houses</option>
<option value="TWNHS">Townhouses</option>
<option value="LOFTS">Lofts</option>
<option value="LND">Land</option>
</select>
SCRIPT
<script>
$(document).ready(function () {
$('select#typeof_dwelling').change(function () {
alert($(this).val());
}
});
</script>
如何使用当前选项值显示此警报?
答案 0 :(得分:2)
修复您的代码,它会起作用。您缺少关闭括号
$(document).ready(function () {
$('select#typeof_dwelling').change(function () {
alert($(this).val());
}); // <-- here
});