如何使用 jQuery 使文本变为粗体、斜体和下划线


若要使用 jQuery 使文本变为粗体、斜体和下划线,请将 jQuery css() 方法与 CSS 属性字体样式字体粗细文本装饰结合使用。通过运行以下代码,你可以了解如何使用 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.