Prototype - dasherize() 方法



此方法用破折號 (“-”) 替換下劃線字元 (“_”) 的每個例項。

語法

string.dasherize();

返回值

返回一個字串。

範例

<html>
   <head>
      <title>Prototype examples</title>
      <script type = "text/javascript" src = "/javascript/prototype.js"></script>
      
      <script>
         function showResult() {
            var str = 'border_bottom_width';
            alert("border_bottom_width.dasherize():"+str.dasherize());
         }
      </script>
   </head>

   <body>
      <p>Click the button to see the result.</p>
      <br />
      <br />
      <input type = "button" value = "Result" onclick = "showResult();"/>
   </body>
</html>

輸出

prototype_string_processing.htm
廣告
© . All rights reserved.