代码编辑器:
x
1
主页: <input type="url" id="myURL">
2
<p>点击按钮设置 URL 字段为只读</p>
3
<p><strong>提示:</strong> 为了查看效果,尝试在点击按钮前后在URL字段中输入内容</p>
4
<button onclick="myFunction()">点我</button>
5
<p id="demo"></p>
6
<script>
7
function myFunction() {
8
document.getElementById("myURL").readOnly = true;
9
}
10
</script>
11