AI编程助手
AI免费问答

JS实现页面颜色改变代码

小云云   2018-02-26 09:18   1890浏览 原创

本文将和大家js的一个网页制作小技巧,应用在很多地方,通过js改变html页面的颜色,有兴趣的学习下,希望能帮助到大家。

我们先来看下具体的演示效果图

以下就是完整的HTML页面代码,大家可以测试下。


nbsp;html> 
 
 
  <meta> 
  <title>Document</title> 
  <style> 
    .big_box{ 
      width: 500px; 
      height: 500px; 
      border: 1px solid black; 
    } 
    .big_box input{ 
      margin-left: 60px; 
    } 
  </style> 
  <script> 
    function Change_red(){ 
      var Red=document.getElementById("change_style"); 
      Red.style.backgroundColor="red"; 
    } 
    function Change_blue(){ 
      var Blue=document.getElementById("change_style"); 
      Blue.style.backgroundColor="blue"; 
    } 
    function Change_green(){ 
      var Green=document.getElementById("change_style"); 
      Green.style.backgroundColor="green"; 
    } 
  </script> 
 
 
  <p> 
    <input> 
    <input> 
    <input> 
  </p> 
 
声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。