开发者

Change all inputs with readonly attribute to disabled instead using jQuery

开发者 https://www.devze.com 2023-04-01 07:28 出处:网络
I\'m having trouble with my jQuery syntax.Could someone show me how to iterate through all controls on a form that have the readonly attribute, remove the readonly attribute, and make then disabled in

I'm having trouble with my jQuery syntax. Could someone show me how to iterate through all controls on a form that have the readonly attribute, remove the readonly attribute, and make then disabled instead? T开发者_Go百科hank you.


$('input[readonly="readonly"]').removeAttr("readonly").prop("disabled",true);


 $("#formID").each('input[readonly="readonly"]', function () {                
       $(this).removeAttr("readonly");
       $(this).attr("disabled", true);
 });

Not sure if you are doing this on page load, or on a link/button click, but this is a start.


$('#your_form_id [readonly]').removeAttr("readonly").prop("disabled",true);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号