HTML DOM Input Search readOnly property
HTML DOM Input Search readOnly属性用于设置或返回输入搜索字段是否为只读。 readOnly属性使该元素不可编辑,但仍可以通过制表符或单击将其聚焦。 如果只读元素中存在默认值,则在提交时将其发送到服务器。
句法
以下是-的语法
设置readOnly属性-
1 | searchObject.readOnly = true|false |
在这里,true表示搜索字段是只读的,而false表示否则。 默认情况下,readOnly属性设置为false。
例
让我们看一下Search readOnly属性的示例-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <!DOCTYPE html> <html> <body> Search readOnly property <form> FRUITS: <input type="search" id="SEARCH1" name="fruits"> </form> <p><center>[wp_ad_camp_3]</center></p><p> Change the readOnly property of the above field by clicking the below button </p> <button onclick="changeRead()">CHANGE</button> function changeRead() { document.getElementById("PASS1").readOnly = true; } </body> </html> |
输出量
这将产生以下输出-
点击"更改"按钮时-