2009 年 6 月 10 日
jQueryによる、属性変更
セレクタ.attr("属性名");
でそのセレクタの属性を取得できます。
title = $(“img”).attr(“title”);
変更する場合は、
セレクタ.attr("属性名","値");
となるらしいです。
多くの属性を変更する場合は
$("img").attr({ src: "/images/hat.gif", title: "jQuery", alt: "jQuery Logo" });
セレクタ.attr("属性名");
でそのセレクタの属性を取得できます。
title = $(“img”).attr(“title”);
変更する場合は、
セレクタ.attr("属性名","値");
となるらしいです。
多くの属性を変更する場合は
$("img").attr({ src: "/images/hat.gif", title: "jQuery", alt: "jQuery Logo" });