在CSS里面写事件,就是通过Expression把JS脚本写在样式中
例如:
<html>
<head>
<title>CSS中写JS脚本</title>
<style type="text/css">
li
{
/*
通过 Expression 来实现JS脚本的插入。 :(冒号)前面的部分是为操作对象的样式属性用来接收函数返回值。(无返回值,可写任意字符)
Expression(在这里写出要触发的事件名称=相对应的JS函数)
*/
x:Expression(onmouseover=function(){this.style.color="Red";});
xx:Expression(onmouseout=function(){this.style.color="#000000";});
}
</style>
</head>
<body>
<ul>
<li>xxxxxxxxxx</li>
<li>XXXXXXXXXX</li>
</ul>
<body>
</html>