.style( "style_property" [, "new_style_value" ] )
This function helps to get a specified style value of an element. style_property is mandatory input to this function.
This function also sets the style value of an element using the second parameter.
Parameters
NameTypeDefaultPossibleDescription
style_propertyStringStyleStyle name should be given and the format should be css style. More than one word style names should be separated by hyphen (-) Eg: background-color
new_style_valueStringOptionalValueNew style value which should be applied to the element
Returns
TypeDescription
StringCurrent style value of the element
Example 1
This example fetches and shows few style properties of div. Click on "Get Style Info".
JS HTML CSS
		$.domLoaded(function() {
			
			$.get("#btn1").on("click", function() {			
			
				var box = $.get("#box");
				
				// Get few styles
				var backColor = box.style("background-color");
				var borderWid = box.style("border-width");
				var color = box.style("color");
				var height = box.style("height");
				
				$.get("#msg").html("background-color : " + backColor
				           + "<br/>border-width : " + borderWid
				           + "<br/>color : " + color
				           + "<br/>height : " + height);
			});

		});							
						
<body>
	
	<div id="box">Box</div>
	
	<div id="msg">Style Info</div>
		
	<br/>
	<input type="button" id="btn1" value="Get Style Info" /> 

</body>
	div {
		float: left;
		padding : 10px;
		margin : 5px;
	}
	
	#box {
		width : 100px;
		height : 100px;
		border : 10px solid #000;
		background-color : yellowgreen;
		color : white;
	}
	
	#msg {
		width : 250px;
		height : 100px;
	}
Result
Example 2
Apply different styles to div using .style(). This example applies background-color, border, width, height and color.
JS HTML CSS
		$.domLoaded(function() {
			
			var box = $.get("#box");
			
			$.get("#btn1").on("click", function() {							
				// Get Background Color
				box.style("background-color", "yellowgreen");	
			});
			
			$.get("#btn2").on("click", function() {							
				// Set width and Height
				box.style("height", "100px");
				box.style("width", "100px");						
			});
			
			$.get("#btn3").on("click", function() {							
				// Set Border and Color
				box.style("border", "10px solid #000");
				box.style("color", "#fff");	
			});		
			
		});						
				
						
<body>
	
	<div id="box">Box</div>
		
	<br />

	<input type="button" id="btn1" value="Set Background Color" /> 
	<input type="button" id="btn2" value="Set Width and Height" /> 
	<input type="button" id="btn3" value="Set Border and Color" /> 

</body>
	div {
		display : inline-block;
		padding : 10px;
		margin : 5px;
	}
Result