如何在实现在网页中,鼠标经过超连接时出现下划线效果

如题所述

<html>
<style>#a1{
color: black; //在css里设置超链接为黑色
text-decoration: none; //在css里设置超链接不显示下划线
}
</style>
<body><a href="" id="a1" onmouseover="setText()" onmouseout="setText1()">《用户服务协议》</a>//body里添加超链接,并且为超链接添加事件
</body>
<script>function setText(){
document.getElementById("a1").style.textDecoration="underline";
}//鼠标移动到超链接时超链接显示下滑线
function setText1(){
document.getElementById("a1").style.textDecoration="none";
}//鼠标移动到超链接时超链接不显示下滑线
</script>
</html>
温馨提示:答案为网友推荐,仅供参考
第1个回答  2016-11-12
a标签本身默认就有text-decoration:underline;属性。
相似回答