Prototype-element-writeattribute

提供:Dev Guides
2020年6月23日 (火) 02:07時点におけるMaintenance script (トーク | 投稿記録)による版 (Imported from text file)
(差分) ← 古い版 | 最新版 (差分) | 新しい版 → (差分)
移動先:案内検索

プロトタイプ-writeAttribute()メソッド

このメソッドは、ハッシュまたは名前/値のペアとして渡された属性を追加、指定、または削除します。

構文

element.writeAttribute(attribute[, value]);

OR

element.writeAttribute(attributes);

戻り値

HTML要素。

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>

      <script>
         function showResult() {
            $('test').writeAttribute("align", "right" );
         }
      </script>
   </head>

   <body>
      <p id = "test" align = "center" >Formatted Paragraph</p>
      <br/>
      <input type = "button" value = "Click" onclick = "showResult();"/>
   </body>
</html>

出力