<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                # JavaScript 字符串(String)對象 **String 對象用于處理已有的字符塊。** ## JavaScript String(字符串)對象 實例 [計算字符串的長度](/tiy/t.asp?f=jsrf_string_length) 如何使用長度屬性來計算字符串的長度。 ``` <html> <body> <script type="text/javascript"> var txt="Hello World!" document.write(txt.length) </script> </body> </html> ``` [為字符串添加樣式](/tiy/t.asp?f=jsrf_string_style) 如何為字符串添加樣式。 ``` <html> <body> <script type="text/javascript"> var txt="Hello World!" document.write("<p>Big: " + txt.big() + "</p>") document.write("<p>Small: " + txt.small() + "</p>") document.write("<p>Bold: " + txt.bold() + "</p>") document.write("<p>Italic: " + txt.italics() + "</p>") document.write("<p>Blink: " + txt.blink() + " (does not work in IE)</p>") document.write("<p>Fixed: " + txt.fixed() + "</p>") document.write("<p>Strike: " + txt.strike() + "</p>") document.write("<p>Fontcolor: " + txt.fontcolor("Red") + "</p>") document.write("<p>Fontsize: " + txt.fontsize(16) + "</p>") document.write("<p>Lowercase: " + txt.toLowerCase() + "</p>") document.write("<p>Uppercase: " + txt.toUpperCase() + "</p>") document.write("<p>Subscript: " + txt.sub() + "</p>") document.write("<p>Superscript: " + txt.sup() + "</p>") document.write("<p>Link: " + txt.link("http://www.w3school.com.cn") + "</p>") </script> </body> </html> ``` [indexOf() 方法](/tiy/t.asp?f=jsrf_string_indexof) 如何使用 indexOf() 來定位字符串中某一個指定的字符首次出現的位置。 ``` <html> <body> <script type="text/javascript"> var str="Hello world!" document.write(str.indexOf("Hello") + "<br />") document.write(str.indexOf("World") + "<br />") document.write(str.indexOf("world")) </script> </body> </html> ``` [match() 方法](/tiy/t.asp?f=jsrf_string_match) 如何使用 match() 來查找字符串中特定的字符,并且如果找到的話,則返回這個字符。 ``` <html> <body> <script type="text/javascript"> var str="Hello world!" document.write(str.match("world") + "<br />") document.write(str.match("World") + "<br />") document.write(str.match("worlld") + "<br />") document.write(str.match("world!")) </script> </body> </html> ``` [如何替換字符串中的字符 - replace()](/tiy/t.asp?f=jseg_replace_1) 如何使用 replace() 方法在字符串中用某些字符替換另一些字符。 ``` <html> <body> <script type="text/javascript"> var str="Visit Microsoft!" document.write(str.replace(/Microsoft/,"W3School")) </script> </body> </html> ``` ## 完整的 String 對象參考手冊 請查看我們的 [JavaScript String 對象參考手冊](/jsref/jsref_obj_string.asp),其中提供了可以與字符串對象一同使用的所有的屬性和方法。 這個手冊包含的關于每個屬性和方法的用法的詳細描述和實例。 ## 字符串對象 字符串對象用于處理已有的字符塊。 ### 例子: 下面的例子使用字符串對象的長度屬性來計算字符串的長度。 ``` var txt="Hello world!" document.write(txt.`length`) ``` 上面的代碼輸出為: ``` 12 ``` 下面的例子使用字符串對象的toUpperCase()方法將字符串轉換為大寫: ``` var txt="Hello world!" document.write(txt.`toUpperCase()`) ``` 上面的代碼輸出為: ``` HELLO WORLD! ``` ## 相關頁面 JavaScript 高級教程:[ECMAScript 類型轉換](/js/pro_js_typeconversion.asp "ECMAScript 類型轉換") JavaScript 高級教程:[ECMAScript 引用類型](/js/pro_js_referencetypes.asp "ECMAScript 引用類型") JavaScript 參考手冊:[String 對象](/jsref/jsref_obj_string.asp "JavaScript String 對象參考手冊")
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看