input清空和重置select下拉框


背景

一般页面搜索条件都会有input输入框和select选择框,同时页面上都会有重置reset按钮,这时就需要清空input和重置select


 

实现

清空input

清空单个input:

$("inputId").val("");

清空div下所有input:

$("#divId input").val("");

 

重置select

重置单个select:

 

    $("#selectId option").removeAttr("selected");//选择出所有option,然后删除selected属性

或者

$("#selectId").find("option:selected").removeAttr("selected");//选择出所有被选择的option,删除其selected属性

 

重置div下多个select:

$("#divId select").each(function ()
{
    $(this).find("option:selected").removeAttr("selected");
});

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM