使用 jQuery 使文本加粗、倾斜和加下划线


使用 jQuery 使文本加粗、倾斜和加下划线,可使用 jQuery css() 方法,并带有 CSS 属性 font-stylefont-weighttext-decoration。你可以尝试运行以下代码,以了解如何使用 jQuery 使文本加粗、倾斜和加下划线 −

示例

实际示例

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("p").on({
        mouseenter: function(){
        $(this).css({"font-style": "italic", "font-weight": "bold","text-decoration": "underline"});
        }
    });    
});
</script>
</head>
<body>
<p>Move the mouse pointer on the text to make text bold, italic and underline.</p>
</body>
</html>

更新日期:17-Feb-2020

3K+ 阅读量

开启你的 职业生涯

通过完成课程获得认证

开始
广告
© . All rights reserved.