$('#area').change(function(){
if(this.options[0].value==-1){
this.options[0]=null;
$('#show').val() = this.value; // 錯誤:val() 不能作為左值
}
});
$('#show').val() = ... 語法非法,.val() 返回值不可賦值。document.getElementById('show').value = this.value 正確,但 jQuery 需用 .val(value) 設置。$('#area').change(function(){
var $this = $(this);
if ($this.find('option:first').val() == '-1') {
$this.find('option:first').remove();
}
$('#show').val($this.find('option:selected').text()); // 或 .val()
});
建議:統一使用 jQuery 方法操作 DOM,避免混用原生屬性導致錯誤。