Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Define Multiple CSS Attributes in jQuery



To define multiple CSS attributes in jQuery, use the css selector or the addClass() method. Let’s see how to do it using css selector.

Pair up strings representing property names with the corresponding values.

Example

You can try to run the following code to learn how to define multiple CSS attributes in jQuery:

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(){
$("#demo").css({
    "background-color": "#F1F1F1",
    "font-style"     : "italic"
});
   
});
</script>

</head>
<body>
<h1 id="demo">Countries</h1>

</body>
</html>
Updated on: 2019-12-17T09:26:57+05:30

2K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements