天天看点

javascript操作a标签属性

注意是style.textDecoration

而不是style.text-decoration

浏览器不识别js中的text-decoration

说明:

该代码尽在chrome,firefox环境下,测试运行正常;

在IE6.0环境下下,测试无效果;

在IE7+ 环境下,未测试;

附上代码:

<script type="text/javascript">

 <!--

 //alert("132")

 -->

function changeColor(num){

    document.getElementById("rowcolumn_"+num).style.color="red";

    document.getElementById("rowcolumn_"+num).style.textDecoration="underline";

}

function changeColorTwo(num){

    document.getElementById("rowcolumn_"+num).style.color="black";bulldog

    document.getElementById("rowcolumn_"+num).style.textDecoration="none";

}

</script>

</head>

<body>

<a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" style="text-decoration:none; color:#000000;" id="rowcolumn_1" οnmοuseοver="changeColor('1');" οnmοuseοut="changeColorTwo('1');" >11111</a> <br/>

<a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" style="text-decoration:none; color:#000000;" id="rowcolumn_2" οnmοusemοve="changeColor('2');"  οnmοuseοut="changeColorTwo('2');">22222222</a> <br/>

<a href="#" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" target="_blank" rel="external nofollow" style="text-decoration:none; color:#000000;" id="rowcolumn_3" οnmοusemοve="changeColor('3');"  οnmοuseοut="changeColorTwo('3');">33333333</a> <br/>

</body>

</html>

注意是style.textDecoration

而不是style.text-decoration

浏览器不识别js中的text-decoration

说明:

该代码尽在chrome,firefox环境下,测试运行正常;

在IE6.0环境下下,测试无效果;

在IE7+ 环境下,未测试;

转载于:https://www.cnblogs.com/ctou45/archive/2011/05/16/2047759.html

继续阅读