How to disable all text box input and drop-down box select in the form, the effect is read-only mode

The first step:
(1) Add a label <fieldset> outside the form form

<fieldset style="border: none;">
    <form>内容...</form>
</fieldset>
那什么是fieldest 呢 我不知道 我简单查了一下,大概就是
< fieldset > 标签将表单内容的一部分打包,生成一组相关表单的字段。

The second step:
(2) When I need to disable, set disabled to <fieldset>

 //禁用掉from表单的内容
 $("fieldset").attr("disabled", "disabled");

At this time, the input has become read-only mode, but the drop-down box can still be clicked

Step 3:
(3) Add styles to the style

/*当用fieldset标签 禁用的时候 用css配合一下*/
    fieldset[disabled] {
    
    
        -ms-pointer-events:none;
        pointer-events: none;
    }

At this time, I have achieved the effect I want, and I hope you can too!

Guess you like

Origin blog.csdn.net/weixin_47336389/article/details/122201095