通常的方法每每給表單的各個input、select等加上readonly,可是這個方法有不少缺點。此處就不一一贅述。
我說的方法只須要給表單加上一個類,就能夠讓表單只讀。segmentfault
<form class="form-readonly"></form>
.form-readonly{ position: relative; } .form-readonly:before{ content: ""; z-index: 1; position: absolute; top: 0; right: 0; bottom: 0; left: 0; }
.form-readonly{ pointer-events:none; }
關於pointer-events屬性,能夠看看這個介紹:https://segmentfault.com/a/11...code