本文实例讲述了JavaScript字符串对象(string)基本用法。分享给大家供大家参考,具体如下:
1.获取字符串的长度:
@H_403_5@
2.为字符串添加各种样式,如:
Big: " + txt.big() + "")
document.write("
"); document.write(hw_text.indexOf("abc")+"
"); @H_403_5@
Small: " + txt.small() + "
") document.write("Bold: " + txt.bold() + "
") document.write("Italic: " + txt.italics() + "
") document.write("Blink: " + txt.blink() + " (does not work in IE)
") document.write("Fixed: " + txt.fixed() + "
") document.write("Strike: " + txt.strike() + "
") document.write("Fontcolor: " + txt.fontcolor("Red") + "
") document.write("Fontsize: " + txt.fontsize(16) + "
") document.write("Link: " + txt.link("//www.jb51.cc") + "
") @H_403_5@ "); document.write(hw_text.indexOf("world")+""); document.write(hw_text.indexOf("abc")+"
"); @H_403_5@
4.内容替换: