zoukankan      html  css  js  c++  java
  • Js 通过点击改变css样式

    通过js 点击按钮去改变目标原始的背景颜色

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <title>Change.html</title>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        
        <!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
      <script language="javascript">
         function test4(event) {
    	   if(event.value == "11") {
    	      //?取div1
    	      var div1 = document.getElementById('div1');
    	      div1.style.backgroundColor="black";
    	   }
    	   if(event.value == "22") {
    	      //?取div1
    	      var div1 = document.getElementById('div1');
    	      div1.style.backgroundColor="red";
    	   }
    	 }
      </script>
    </head>
    <body>
      <div id="div1" style="400px; height:300px; background-color:red;">div1</div>
      <input type="button" value="11" onclick="test4(this)"/>
      <input type="button" value="22" onclick="test4(this)"/>
    
      </body>
    </html>
    
  • 相关阅读:
    mysql总结
    git总结
    转:如何判断一家公司的好坏
    路越走越窄,尤其做技术的
    百度面试总结
    背叛
    which和whereis 命令
    bzoj3263 陌上花开 CDQ模板
    bzoj 2653middle
    暑假第十九测
  • 原文地址:https://www.cnblogs.com/sunxun/p/4324174.html
Copyright © 2011-2022 走看看