How to make text bold, italic and underline using jQuery


To make text bold, italic and underline using jQuery, use the jQuery css() method with the CSS properties font-style, font-weight and text-decoration. You can try to run the following code to learn how to make text bold, italic and underline using jQuery −

Example

Live Demo

<!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>

Updated on: 17-Feb-2020

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements