日期:2014-05-17  浏览次数:20629 次

帮忙看个span的css
这是我用js写的,麻烦大伙帮我改成css形式好吗?我是不太会写那个鼠标事件...谢谢
JScript code

var spans = document.getElementsByTagName("span");
for (var j = 0; j < spans.length; j++) {
    spans[j].style.color = "blue";
    spans[j].onmouseover = function overThis(){
        this.style.color = "red";
        this.style.cursor="hand";
        this.style.textDecoration = "underline";
    };
    spans[j].onmouseout = function outThis(){
        this.style.color = "blue";
        this.style.cursor="";
        this.style.textDecoration = "none";
    }
}



------解决方案--------------------

你的代码能用 改下
HTML code



<html>
<head>
<title></title>

</head>
<body>
<span>aaa </span><br>
<span>bbb </span><br>
<span>ccc </span><br>
<span>ddd </span><br>
<span>eee </span><br>
</body>
<script>
function overThis(){
        this.style.color = "red";
        this.style.cursor="hand";
        this.style.textDecoration = "underline";
    }
    function outThis(){
        this.style.color = "blue";
        this.style.cursor="";
        this.style.textDecoration = "none";
    }
   var spans = document.getElementsByTagName("span");
    for (var j = 0; j < spans.length; j++) {
        spans[j].style.color = "blue";
        spans[j].onmouseover = overThis;
        spans[j].onmouseout = outThis;
    }


</script>

</html>

------解决方案--------------------
对不起,后面的textDecoration忘了加this.style.了。

CSS code

color = "blue";
onmouseover: expression(onmouseover=function (){this.style.color ='red';this.style.cursor='hand';this.style.textDecoration = 'underline'});
onmouseout: expression(onmouseout=function (){this.style.color ='blue';this.style.cursor='';this.style.textDecoration = ''});

------解决方案--------------------
CSS code

SPAN{
star:expression(
    onmouseover=function(){
        this.style.color = "red";
        this.style.cursor="hand";
        this.style.textDecoration = "underline";
        },
    onmouseout=function(){
        this.style.color = "blue";
        this.style.cursor="";
        this.style.textDecoration = "none";
    }
);
color:blue
}