<!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" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<title>Document</title>
<style>
#box{
width:100px;
height:100px;
background-color: red;
}
</style>
<!--js部分,鼠标滑过盒子的时候,盒子颜色由原来的红色变成绿色,当鼠标从盒子上离开,盒子的颜色又恢复为原来的红色-->
<script>
window.onload=function(){ //function后面的括号不要忘记
function $id(id) //$id(id) 这个函数是用来获取id的
{
return document.getElementById(id); //id是形参变量,不加引号
}
$id("box").onmouseover=function(){ //调用的时候一定要加引号
$id("box").style.backgroundColor="green";
}
$id("box").onmouseout=function(){
$id("box").style.backgroundColor="red";
}
}
</script>
</head>
<body>
<div id="box"></div>
</body>
</html>

随机推荐

  1. 安装Dubbo 并且安装注册中心(Zookeeper-3.3.6)

    安装zookeeper 安装Tomcat 载dubbo-admin-2.5.4.war 进入Apache ZooKeeper官方网站进行下载,https://zookeeper.apache.org/ ...

  2. C++入门经典-例6.7-字符串比较

    1:strcmp函数,用于比较两个字符串.格式如下: strcmp(字符数组名1,字符数组名2) 按照ASCII码,按顺序比较两个数组中的字符,并由函数返回值返回比较结果的执行过程. (1)各自选中自 ...

  3. C++入门经典-例3.14-使用while循环计算从1到10的累加

    1:代码如下: // 3.14.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream> usin ...

  4. spring-ApplicationContext的事件传播(转)

    ApplicationContext中的事件处理是通过ApplicationEvent类和ApplicationListener接口来提供的,通过ApplicationContext的publishE ...

  5. shell编程常用命令

    Linux中常用的命令 #nl  filename   使用nl命令打印文件内容并显示行号 #sed   '/nw/,$d'   filename     使用sed命令删除匹配nw至最后一行的内容 ...

  6. 三种CSS样式

    内联式css样式,直接写在现有的HTML标签中 CSS样式可以写在哪些地方呢?从CSS 样式代码插入的形式来看基本可以分为以下3种:内联式.嵌入式和外部式三种. 内联式css样式表就是把css代码直接 ...

  7. C++ Vector实践

    实践如下: #include <iostream> #include <vector> #include <typeinfo> using namespace st ...

  8. 关于Layui的表格中分页处理

    table.render({ elem: '#test' ,height:'full-125' ,url:'data.php' ,cellMinWidth: 80 //全局定义常规单元格的最小宽度,l ...

  9. rsync启动脚本

    rsync启动脚本 01 #!/bin/bash  www.ahlinux.com 02 # 03 # rsyncd      This shell script takes care of star ...

  10. Linux (1)

    @https://blog.csdn.net/mayi_xiaochaun这人博客里有一系列linux教程 @linux中,文件名最前加/  比如 cd /usr/local是绝对路径 若#前显示当前 ...