如何使用 jQuery 更改"text-decoration"属性?
jqueryweb developmentfront end technology
要使用 jQuery 更改文本装饰属性,请使用 jQuery css() 属性。
示例
您可以尝试运行以下代码,将 text-decoration 属性从下划线更改为上划线:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$("p").on({
mouseenter: function(){
$(this).css({"text-decoration": "overline"});
}
});
});
</script>
<style>
p {
text-decoration: underline;
}
</style>
</head>
<body>
<p>Move the mouse pointer on the text to remove underline and add overline.</p>
</body>
</html>

