Prototype-element-setstyle

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

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

このメソッドは、要素のCSSスタイルプロパティを変更します。 スタイルは、プロパティとキャメル形式で指定されたプロパティと値のペアのハッシュとして渡されます。

構文

element.setStyle(styles);

戻り値

HTML要素を返します。

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

      <script>
         function setColor() {
            $('test').setStyle({
               backgroundColor: '#900',
               fontSize: '12px'
            });
         }
      </script>
   </head>

   <body">
      <p id = "test">Click the button to see the result.</p>
      <input type = "button" value = "Click" onclick = "setColor();"/>
   </body>
</html>

出力