久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放AV片

<center id="vfaef"><input id="vfaef"><table id="vfaef"></table></input></center>

    <p id="vfaef"><kbd id="vfaef"></kbd></p>

    
    
    <pre id="vfaef"><u id="vfaef"></u></pre>

      <thead id="vfaef"><input id="vfaef"></input></thead>

    1. 站長資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript怎么設置input框為只讀

      設置方法:1、使用“document.getElementById(id)”語句根據(jù)指定id值獲取input元素對象;2、使用“input對象.setAttribute("readOnly", true)”語句給input元素添加只讀樣式。

      javascript怎么設置input框為只讀

      本教程操作環(huán)境:windows7系統(tǒng)、javascript1.8.5版、Dell G3電腦。

      在javascript中,想要設置input框為只讀,只需要使用setAttribute()方法給input元素添加只讀屬性–readOnly即可。

      setAttribute() 方法添加指定的屬性,并為其賦指定的值。

      語法:

      element.setAttribute(attributename,attributevalue)

      示例:

      <!DOCTYPE html> <html> 	<head> 		<meta charset="UTF-8"> 	</head> 	<body> 		<input type="text" id="text" /><br><br> 		<input type="button" value="設為只讀" id="btn" /> 		<script> 			function my(id) { 				return document.getElementById(id); 			} 			my("btn").onclick = function() { 				my("text").setAttribute("readOnly", true); 			} 		</script> 	</body> </html>

      javascript怎么設置input框為只讀

      贊(0)
      分享到: 更多 (0)
      網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號