Learn jQuery

jQuery css()

jQuery css() method sets or returns one or more style properties for the matched elements.

Syntax

jQuery.css(Property name) // Return css Property for the matched elements jQuery.css("Property name","Property value"); // Set css Property for the matched elements jQuery.css({"Property name1":"Property value1","Property name2":"Property value2"}) // Set Multiple css Properties

Example

HTML
<!DOCTYPE html>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"> </script>
<title>jQuery css() Example </title>
</head>
<div class="myDiv">Hello, I am div. </div>
<input type="button" value="Press Me" id="pressToAdd">
<div></div>
</html>
Javascript
$(document).ready(function(){
$("#pressToAdd").click(function () {
$(".myDiv").css({"background-color":"#755779","width":"200","margin-bottom":"20px"});
});
});