html对input、div或其他标签设置不可修改

最近有时间,就整理整理自己做过的项目~这是某学院的档案系统项目。
话不多说,进入正题

业务: 档案管理员可把档案字段设置为不可修改,即只可读。
解决: 如果遍历出来的changed为1,则该字段不可修改。

1.对input标签,我们可以采取这种方式:

<input th:readonly="${changed}==1"/>

2.对于其他标签,我们可以加个div:

 <div th:style="${changed}?'pointer-events: none;':''">

关键就是:给div的style添加pointer-events: none;


关于这个,有任何问题可以留言问我(๑•ᴗ•๑)~

觉得还不错可以点个赞哦~ 谢谢(๑•ᴗ•๑)

发布了52 篇原创文章 · 获赞 84 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/qq_39380155/article/details/103669060
今日推荐