使用 jQuery 使文字加粗、傾斜和加下劃線


使用 jQuery 使文字加粗、傾斜和加下劃線,可使用 jQuery css() 方法,並帶有 CSS 屬性 font-stylefont-weighttext-decoration。你可以嘗試執行以下程式碼,以瞭解如何使用 jQuery 使文字加粗、傾斜和加下劃線 −

示例

實際示例

<!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({"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+ 閱讀量

開啟你的 職業生涯

透過完成課程獲得認證

開始
廣告