zoukankan      html  css  js  c++  java
  • JS控制页面样式

    .

    .

    .

    .

    鼠标悬浮的时候改变文本框和按钮的颜色、背景图片以及链接文字的大小。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
    <title>JS控制CSS</title>
    <style type="text/css">
    <!--
    .txtTest {
    	height: 15px;
    	 200px;
    	border: thin dashed #0000FF;
    }
    .txtOutTest {
    	height: 15px;
    	 200px;
    	border: thin dashed #FF6600;
    }
    .btnSub {
    	background-image:url(back1.jpg);
    	height: 23px;
    	 82px;
    	border:0;
    }
    -->
    </style>
    <script>
    	var tmr;
    	function Over(){
    		document.getElementById("btnSub").style.backgroundImage="url('back2.jpg')";
    		clearTimeout(tmr);
    	}
    	function Out(){
    		document.getElementById("btnSub").style.background="url('back1.jpg')";
    		Overs();
    	}
    	function Overs(){
    		document.getElementById("btnSub").style.backgroundImage="url('back1.jpg')";
    		tmr = setTimeout("Outs();",500);
    	}
    	function Outs(){
    		document.getElementById("btnSub").style.background="url('back2.jpg')";
    		tmr = setTimeout("Overs()",500);
    	}
    </script>
    </head>
    
    <body>
    <p><a href="#" style="font-size:12px;" onmouseover="this.style.fontSize='36px';" onmouseout="this.style.fontSize='12px';">这个链接可以改变大小</a></p>
    <p>
      <input name="textfield" type="text" class="txtTest" id="txtTest" onmouseover="this.className='txtOutTest'" onmouseout="this.className='txtTest'" />
    </p>
    <p>
      <input id="btnSub" type="button" class="btnSub" value="按钮" onmouseover="Over()" onmouseout="Out()" />
    </p>
    </body>
    </html>
    
  • 相关阅读:
    宏 定 义 编 译 出 错
    SSWR 跟 进一法除法
    显示文件后缀扩展名
    基于MPLAB X IDE配置位设置讲解
    mplab xIde 编译成功,但不能生成Hex文件
    InputStream 、 InputStreamReader 、 BufferedReader
    MPLAB® XC C编译器的Workstation License的获取及安装方法
    MPLAB设置路径
    js中的cookie及封装
    nodejs中使用node-sass
  • 原文地址:https://www.cnblogs.com/0xcafebabe/p/2073653.html
Copyright © 2011-2022 走看看