JavaScript[对象.属性]集锦之八

**string对象

** string对象为操作字符串的内容提供了很多方法.

属性

length 字符串的长度,即字符串中字符的个数.

方法

big(),blink(),bold(),fixed(),italics(),small(),sub(),strike(),sup(),fontColor(color),fontSize(size)

以上方法为字符串增加相应的HTML标记.

charAt(index) 返回字符串中index处的字符.

indexOf(searchValue,[fromIndex]) 该方法在字符串中寻找第一次出现的searchValue.如果给定了fromIndex,则从

字符串内该位置开始搜索,当searchValue找到后,返回该串第一个字符的位置.

lastIndexOf(searchValue,[fromIndex]) 从字符串的尾部向前搜索searchValue,并报告找到的第一个实例.

substring(indexA,indexB) 获取自indexA到indexB的子串.

toLowerCase(),toUpperCase() 将字符串中所有字符全部转换成大写,小写.

Published At
Categories with 网页设计
comments powered by Disqus