If checkbox, radio or select elements are unmodifiable in HTML for some reason, invoke $([$selector]).readonly() to make them unselectable via js code.
Notice that they are just unable to be selected instead of having a [readonly] or [disabled] attribute.
These elements will have class "readonly-item" for your customized styles.
可以通过调用$([$selector]).readonly()方法来让checkbox、radio或select标签变成只读,不可编辑.
这种方法只会让标签不可编辑,而不会为其添加[readonly]或[disabled]属性,不会影响其提交值.
这些标签会被添加class:"readonly-item",以允许为其制定自定义css样式等.
<select class="readonly-group" name="field30">
<option value=""></option>
<option value="1" selected>label 1</option>
<option value="2">label 2</option>
<option value="3">label 3</option>
</select>
function readonly() {
$(".readonly-group").readonly();
}
Invoke $([$selector]).removeReadonly() to remove these effects.
通过调用$([$selector]).removeReadonly()方法来取消只读.
function removeReadonly() {
$(".readonly-group").removeReadonly();
}