如何使用jQuery在Hover上加下划线?
要在使用jQuery的鼠标悬停时给超链接加下划线,请使用jQuerycss()属性。使用彩色文本装饰属性。
示例
您可以尝试运行以下代码,以了解如何在悬停时给超链接加下划线:
<html>
<head>
<title>jQuery Hyperlink Decoration</title>
<script src = "https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function() {
$('a').hover(
function () {
$(this).css({"text-decoration":"underline"});
});
});
</script>
<style>
a {
text-decoration: none;
}
</style>
</head>
<body>
<a href="#">Demo text</a>
</body>
</html>