读书人

帮忙看个span的css解决思路

发布时间: 2012-02-15 12:09:44 作者: rapoo

帮忙看个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} 

读书人网 >CSS

热点推荐