欧美亚洲中文,在线国自产视频,欧洲一区在线观看视频,亚洲综合中文字幕在线观看

      1. <dfn id="rfwes"></dfn>
          <object id="rfwes"></object>
        1. 站長資訊網(wǎng)
          最全最豐富的資訊網(wǎng)站

          javascript怎么設(shè)置input框?yàn)橹蛔x

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

          javascript怎么設(shè)置input框?yàn)橹蛔x

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

          在javascript中,想要設(shè)置input框?yàn)橹蛔x,只需要使用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="設(shè)為只讀" id="btn" /> 		<script> 			function my(id) { 				return document.getElementById(id); 			} 			my("btn").onclick = function() { 				my("text").setAttribute("readOnly", true); 			} 		</script> 	</body> </html>

          javascript怎么設(shè)置input框?yàn)橹蛔x

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