如何利用jquery來給input或者select控件添加或刪除disabled屬性全部方法總結


前段時間,做了一個前端頁面用到了jquery來來添加或者刪除input和select控件的disabled屬性,具體總結如下:

1.以下二種方法是可以為input添加disabled屬性的方法:
//兩種方法設置disabled屬性
$('#selectId').attr("disabled",true);
$('#selectId').attr("disabled","disabled");

2.以下三種方法是移除(去除)掉input的disabled屬性的方法:
//三種方法移除disabled屬性
$('#selectId').attr("disabled",false);
$('#selectId').removeAttr("disabled");
$('#selectId').attr("disabled","");

3.移除或者刪除所有input和select控件的disabled屬性:

//移除所有select控件的disabled屬性

$("select").each(function () {

$(this).attr("disabled","");
});

//移除所有input控件的disabled屬性:
$("input").attr("disabled","");


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM