: :
<html> <body> <script type = "text/javaScript"> var txt = "hello world!" document.write (txt.length) </script> </body> </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>") "</p>") document.write ("<p> italic:" + txt.italics () + "</p>") document.write ("<p> Blink:" + txt.blink () + "(لا يعمل في ie) </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>") document.write ("<p> uppercase:" + txt.touppercase () + "</p>") document.write ("<p> substript:" + txt.sub () + "</p>") document.write ("<p> superscript: 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 ("hello") + "<br />")document.write(str.indexof("world") + "<br/>") document.write (str.indexof ("world"): :
查找字符串中特定的字符 , 若找到 , 则返回该字符 - 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(str.math processworl") /> ") document.write (str.match (" World! ")) </script> </body> </html>: :
替换字符串中的字符 - استبدال () :
<html> <Body> <script type = "text/javaScript"> var str = "قم بزيارة microsoft!
: :
以上这篇 javaScript String (字符串) 对象的简单实例 (推荐) 就是小编分享给大家的全部内容了 , 希望能给大家一个参考 , 也希望大家多多支持武林网。