天天看點

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

繼續閱讀