久久久久久久视色,久久电影免费精品,中文亚洲欧美乱码在线观看,在线免费播放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. 站長(zhǎng)資訊網(wǎng)
      最全最豐富的資訊網(wǎng)站

      javascript怎么修改元素的style屬性

      在javascript中,可以利用setAttribute()方法來(lái)修改style屬性,該方法可以為一個(gè)已存在的指定屬性修改屬性值,語(yǔ)法“元素對(duì)象.setAttribute("style","樣式代碼");”。

      javascript怎么修改元素的style屬性

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

      在javascript中,可以利用setAttribute()方法來(lái)修改style屬性。

      setAttribute() 方法添加指定的屬性,并為其賦指定的值。如果這個(gè)指定的屬性已存在,則僅設(shè)置/更改值。

      語(yǔ)法:

      element.setAttribute(attributename,attributevalue)
      參數(shù) 類型 描述
      attributename String 必需。您希望添加的屬性的名稱。
      attributevalue String 必需。您希望添加的屬性值。

      示例:

      <!DOCTYPE html> <html> 	<head> 		<meta charset="utf-8"> 	</head> 	<body> 		<div id="box" style="background-color: black;color: white;border: 2px solid red;">一個(gè)div元素</div><br /> 		<button onclick="replaceMessage()"> 修改style屬性的值</a>  			<script type="text/javascript"> 				function replaceMessage() { 					var div = document.getElementById("box");  					div.setAttribute("style","background-color: #FFC0CB;color: black;border: 3px dashed peru;"); 				} 			</script>  	</body> </html>

      javascript怎么修改元素的style屬性

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