Prototype-element-writeattribute

提供:Dev Guides
移動先:案内検索

プロトタイプ-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>

出力