input清空和重置select下拉框
背景
⼀般页⾯搜索条件都会有input输⼊框和select选择框,同时页⾯上都会有重置reset按钮,这时就需要清空input和重置select
实现
清空input
清空单个input:
$("inputId").val("");
清空div下所有input:
$("#divId input").val("");
重置select
重置单个select:
$("#selectId option").removeAttr("selected");//选择出所有option,然后删除selected属性
input框禁止输入或者
$("#selectId").find("option:selected").removeAttr("selected");//选择出所有被选择的option,删除其selected属性
重置div下多个select:
$("#divId select").each(function ()
{
$(this).find("option:selected").removeAttr("selected");
});

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。