一 、 面向对象的javascript
对象:只是一种特殊的数据。对象拥有属性和方法。
(1) 字符串的内置方法
给字符串加样式的方法
<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>") 照片:
Hello World!
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>
(2) indexOf() 来定位字符串中某一个指定的字符首次出现的位置;
lastIndexOf() 从后向前检索。
(3)如何使用 match() 来查找字符串中特定的字符,并且如果找到的话,则返回这个字符;
(4) txt.slice(start,end) 提取字符串指定位置的字符