jQuery CSS ??? ??
css ??? ??
$().css(name, value); //
$().css(name) ??; //Get
$() .css (json object); //?? CSS ???? ??? ??
css() ??? ?? ??:
① ??? ??, jquery? ???, ?? ? ?? ???? ?? ? ????.
dom ???? ??? ???? ?? ? ????
② ?? ?? ???? ???? ?? "?? ???"? ????? ???.
?: ??? ??? ?? ??? ??? ???? ???? ???
???: ???-?? ??? ???-?? ?? ???-??-?? ?
margin: ??-?? ??-?? ?
<!DOCTYPE html> <html> <head> <title>php.cn</title> <meta charset="utf-8" /> <script src="http://libs.baidu.com/jquery/1.10.2/jquery.min.js"></script> <script> function f1(){ alert($('div').css('background-color')); } function f2(){ $('div').css('background-color','red') } function f3(){ var jn={'width':'300px','height':'300px'}; $('div').css(jn); } </script> </head> <body> <div style="width:200px; height:150px; background-color:lightblue;">歡迎大家學習jQuery</div> <input type="button" value="獲取背景色" onclick="f1()" /> <input type="button" value="設置背景色" onclick="f2()" /> <input type="button" value="批量設置" onclick="f3()" /> </body> </html>