如何使用 jQuery 使文字變為粗體、斜體和下劃線


若要使用 jQuery 使文字變為粗體、斜體和下劃線,請將 jQuery css() 方法與 CSS 屬性字型樣式字型粗細文字裝飾結合使用。透過執行以下程式碼,你可以瞭解如何使用 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+ 檢視

開啟你的職業生涯

完成課程,獲得認證

開始
廣告
© . All rights reserved.