Use the css() method to set the styles for <p>: - Javascript jQuery Method and Property

Javascript examples for jQuery Method and Property:css

Introduction

Use the css() method to set the following styles for <p>: Green background color, white text color, 25 pixels font size and a padding of 15 pixels.

Demo Code

ResultView the demo in separate window

<!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").css({//  www  . j  a v  a  2 s .  c  o m
        "background-color": "green",
        "color": "white",
        "font-size": "25px",
        "padding": "15px"
    });
});
</script>
</head>
<body>

<p>This is a paragraph.</p>

</body>
</html>

Related Tutorials