• 将单词首字母大写的JS脚本工具


    <html>
    <head>
    <title>首字母全改为大写JS脚</title>
    <SCRIPT LANGUAGE="JavaScript">
    function changeCase(frmObj) 
    {
     var index;
     var tmpStr;
     var tmpChar;
     var preString;
     var postString;
     var strlen;
     tmpStr = frmObj.value.toLowerCase();
     strLen = tmpStr.length;
     if (strLen > 0)  
     {
      for (index = 0; index < strLen; index++)  
      {
       if (index == 0)  
       {
        tmpChar = tmpStr.substring(0,1).toUpperCase();
        postString = tmpStr.substring(1,strLen);
        tmpStr = tmpChar + postString;
       }
       else 
       {
        tmpChar = tmpStr.substring(index, index+1);
        if (tmpChar == " " && index < (strLen-1)) 
        {
         tmpChar = tmpStr.substring(index+1, index+2).toUpperCase();
         preString = tmpStr.substring(0, index+1);
         postString = tmpStr.substring(index+2,strLen);
         tmpStr = preString + tmpChar + postString;
        }
       }
      }
     }
     frmObj.value = tmpStr;
    }
    </script>
    </head>
    <body>
    <font face="宋体"><span style="font-size: 9pt"> </span></font>
    <center>
      <form name=form>
        <p>
          <textarea  type=text   cols="100"  rows="20" name=box value="type in here and click the !" ></textarea>
          <br >
          <input type=button value="首字母全改为大写" onClick="javascript:changeCase(this.form.box)">
        </p>
      </form>
    </center>
    <center>
      <SCRIPT LANGUAGE="JavaScript">
      function goHist(a)
      {
       history.go(a);
      }
    </script>
    </center>
    </body>
    </html>
  • 相关阅读:
    CSS样式
    hdu 6038 Function
    hdu 6034 Balala Power!
    错排公式 (递推)
    快速求排列组合 lucas定理
    fzu Problem 2275 Game(kmp)
    HDU 3635 Dragon Balls(并查集)
    HDU 3172 Virtual Friends(map+并查集)
    hdu 2818 Building Block(并查集,有点点复杂)
    hdu 1272 小希的迷宫(并查集)
  • 原文地址:https://www.cnblogs.com/riskyer/p/3313214.html
Copyright © 2020-2023  润新知