jQuery日本語リファレンス

jQuery does not mean Japanese Query...

Css/API/jQuery

css(properties)

キーと値がセットになったハッシュを渡すことで、全ての要素のstyle属性を設定します。

全ての要素に同じスタイルをセットしたい場合に便利です。
サンプル
サンプル1
cssメソッドを使って、p要素にマウスが乗った時と外れた時のスタイルを指定します。
<p>
  Move the mouse over a paragraph.
</p>
<p>
  Like this one or the one above.
</p>
$("p").hover(function () {
  $(this).css({ backgroundColor:"yellow", fontWeight:"bolder" });
}, function () {
  var cssObj = {
    backgroundColor: "#ddd",
    fontWeight: "",
    color: "rgb(0,40,244)"
  }
  $(this).css(cssObj);
});
[全コードを表示] [実行結果を単体で表示]