getAttributeで値の取得とsetAttributeで値の設定

getAttributeで値の取得とsetAttributeで値の設定します。

element.getAttribute("className");

element.style.cssText = "スタイルの中身";

element.setAttribute("onclick", new Function("クリックイベント(event);"));

getAttribute は大文字小文字を区別せずプロパティ名を検索しますが、setAttribute は大文字小文字を区別します。

element.getAttributeでの指定方法は結構わかりにくいので、つど調べるひつようがる。

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です