久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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怎么改變圖片寬度

      方法:1、使用“document.getElementById('id值')”語句獲取圖片對象;2、使用“圖片對象.setAttribute("width", "寬度值")”或“圖片對象.style.width="值"”語句改變圖片寬度。

      javascript怎么改變圖片寬度

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

      javascript改變圖片寬度的方法

      <img id="img" src="img/2.jpg" width="500" height="300"/>

      1、根據(jù)id值獲取圖片對象

      var img=document.getElementById('img');

      2、使用setAttribute("width", "值")或者style對象的width屬性來改變圖片寬度

      img.setAttribute("width", "寬度值"); // 或 img.style.width = "寬度值";

      完整實現(xiàn)代碼:

      <!doctype html> <html> 	<head> 		<meta charset="utf-8"> 	</head> 	<body> 		<img id="img" src="img/2.jpg" width="500" height="300" /><br /><br /> 		<button onclick="myFunction()">改變圖片寬度</button> 		<script type="text/javascript"> 			function myFunction() { 				var img = document.getElementById('img'); 				// img.setAttribute("width", "300"); 				img.style.width = "300px"; 			} 		</script> 	</body> </html>

      效果圖:

      javascript怎么改變圖片寬度

      【推薦學習:javascript高級教程】

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