类别是第一个项目,你会看到我希望它被选中后删除或禁用,以便在查看其他下拉菜单项时不显示。
<select NAME="category" style="width:130px; background-color:#FFF; font-weight:bold; font-size:12px;" ONCHANGE="setup(document.search1.category.value)">
<option value="category" selected="selected">Category</option>
<option value="cleaning">Cleaning</option>
<option value="cooling">Cooling</option>
<option value="heating">Heating</option>
<option value="kitchen">Kicthen</option>
<option value="lighting">Lighting</option>
<option value="washroom">Washroom</option>
</select>
答案 0 :(得分:1)
这将删除所选项目
<select NAME="category" style="width:130px; background-color:#FFF; font-weight:bold; font-size:12px;" onchange="this.remove(this.selectedIndex);">
<option value="category" selected="selected">Category</option>
<option value="cleaning">Cleaning</option>
<option value="cooling">Cooling</option>
<option value="heating">Heating</option>
<option value="kitchen">Kicthen</option>
<option value="lighting">Lighting</option>
<option value="washroom">Washroom</option>
</select>
答案 1 :(得分:0)
您应该像disabled = 'disabled'
<select NAME="category" style="width:130px; background-color:#FFF; font-weight:bold; font-size:12px;" onchange="javascript:this.disabled = 'disabled';">
<option value="category" selected="selected">Category</option>
<option value="cleaning">Cleaning</option>
<option value="cooling">Cooling</option>
<option value="heating">Heating</option>
<option value="kitchen">Kicthen</option>
<option value="lighting">Lighting</option>
<option value="washroom">Washroom</option>
</select>
答案 2 :(得分:0)
如果您想在用户从下拉列表中选择其他项目后删除“类别”订单项,则可以执行以下操作:
<script type="text/javascript">
$(document).ready(function () {
$('#selectList').change(function () {
if (this[0].value == "category")
{
this.remove(this[0]);
}
});
});
</script>
<select id='selectList' name="category"
style="width:130px; background-color:#FFF; font-weight:bold; font-size:12px;">
<option value="category">Category</option>
<option value="cleaning">Cleaning</option>
<option value="cooling">Cooling</option>
<option value="heating">Heating</option>
<option value="kitchen">Kicthen</option>
<option value="lighting">Lighting</option>
<option value="washroom">Washroom</option>
</select>
这将从下拉列表和类别行中删除“类别”行。