本文实例讲述了JavaScript字符串对象(string)基本用法。分享给大家供大家参考,具体如下:
1.获取字符串的长度:
2.为字符串添加各种样式,如:
Big: " + txt.big() + "")
document.write("
");
document.write(hw_text.indexOf("world")+"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") + "
")"); document.write(hw_text.indexOf("abc")+"
");