:
<html> <body> <script type = "text / javascript"> var txt = "Hello World!" Document.write (txt.length) </cript> </ody> </html>
:
<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 () + + document ("<p> bold:" + txt.bold () + + "</p>") document.write ("<p> italic:" + txt.alics () + "</p>") document.write ("<p> blink:" + txt.blink () + "(ne fonctionne pas dans ie) </p>") document.write ("<p> fixe:" + txt.fixed () + "</p>") Document.write. " txt.strike () + "</p>") document.write ("<p> fontcolor:" + txt.fontcolor ("red") + "</p>") document.write ("<p> FontSize:" + txt.fonTSize (16) + "</p>") Document.Write ("<p> minuscules:" + txt.toLt. "</p>") document.write ("<p> uppercase:" + txt.touppercase () + "</p>") document.write ("<p> indique:" + txt.sub () + "</p>") document.write ("<p> surscript:" + txt.sup () + "</p>") document.write (" txt.link ("http://www.w3school.com.cn") + "</p>") </ script> </ body> </html>返回字符串中指定文本首次出现的位置 - indexof () 方法:
<html> <body> <script type = "text / javascript"> var str = "Hello world!" document.write (str.indexof ("bonjour") + "<br />")Document.write(str.indexof (" world ") </ script> </ body> </ html>:
查找字符串中特定的字符 , 若找到 , 则返回该字符 - Match () 方法 :
<html> <body> <script type = "text / javascript"> var str = "Hello world!" document.write (str.match ("world") + "<br />")Document.write(str.match("worlld") + "<br />")Document.write(str.match("worlld") + "<rr <br /> ") document.write (str.match (" world! ")) </script> </ body> </html>:
替换字符串中的字符 - remplacer ():
<html> <body> <script type = "text / javascript"> var str = "Visitez Microsoft!" Document.Write (str.replace (/ Microsoft /, "W3School")) </cript> </ body> </html>
:
以上这篇 String javascript (字符串) 对象的简单实例 (推荐) 就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持武林网。