The css() method has three different syntaxes, to perform different tasks. css(name) - Return CSS property value css(name,value) - Set CSS property and value css({properties}) - Set multiple CSS properties and values <script type="text/javascript">$(document).ready(function(){ $("div.ret").click(function(){ $("p.ret").html($(this).css("background-color")); });});</script> <div class="ret" style="width:100px;height:100px;background:#ff0000"></div><p class="ret">Click in the red box to return the background color.</p>
primi elementi jquery
The css() method has three different syntaxes, to perform different tasks. css(name) - Return CSS property value css(name,value) - Set CSS property and value css({properties}) - Set multiple CSS properties and values <script type="text/javascript">$(document).ready(function(){ $("div.ret").click(function(){ $("p.ret").html($(this).css("background-color")); });});</script> <div class="ret" style="width:100px;height:100px;background:#ff0000"></div><p class="ret">Click in the red box to return the background color.</p>