Js中String类型方法用法大全
来源:互联网 发布:iframe 端口不同 跨域 编辑:程序博客网 时间:2024/06/05 06:43
<!DOCTYPE html><html><head><meta charset="utf-8"><title></title></head><body><script>var str="Hello World!";document.write("源字符串:"+str+"<br />")/* * 1、计算字符串的长度,输出结果12 * 2、字符串加粗加黑 * 3、字符串变小 * 4、字符串加粗 * 5、字符串变颜色 * 6、字符串设置大小(1~7) * 7、字符串转大写 * 8、字符串转小写 * 9、上标显示 * 10、下表显示 * 11、加删除线 * 12、加超级连接 * 13、indexOf()用法,当字符串存在,返回第一次出现位置下标 * 14、当字符串不存在,返回-1 * 15、lastIndexOf用法,返回最后一次出现字符串的下标 * 16、match用法,区分大小写,存在则返回,不存在则返回null * 17、字符串替换,replace(),只替换出现的第一个字符,如果全部替换可使用正则表达式 * 18、charAt(),返回数组下标的字母 * 19、concat(),连接字符串 * 20、fromCharCode(),根据字符编码创建一个字符串 * 21、字符串变为斜体 */document.write("1、"+str.length+"<br />");document.write("2、"+str.big()+"<br />")document.write("3、"+str.small()+"<br />")document.write("4、"+str.bold()+"<br />")document.write("5、"+str.fontcolor("Red")+"<br />")document.write("6、"+str.fontsize(7)+"<br />")document.write("7、"+str.toUpperCase()+"<br />")document.write("8、"+str.toLowerCase()+"<br />")document.write("9、"+str+str.sub()+"<br />")document.write("10、"+str+str.sup()+"<br />")document.write("11、"+str.strike()+"<br />")document.write("12、"+str.link("https:\\www.baidu.com")+"<br />")document.write("13、"+str.indexOf("ell")+"<br />")document.write("14、"+str.indexOf("AAA")+"<br />")document.write("15、"+str.lastIndexOf("l")+"<br />")document.write("16、"+str.match("World")+"<br />")document.write("17、"+str.replace("l","*")+"<br />")document.write("18、"+str.charAt(3)+"<br />")document.write("19、"+str.concat("ABC")+"<br />")document.write("20、"+String.fromCharCode(67,68,69)+"<br />")document.write("21、"+str.italics()+"<br />")</script></body></html>
运行结果如下所示:
阅读全文
0 0
- Js中String类型方法用法大全
- js中String类型对象的方法使用
- Js中String对象方法replace()用法详解
- JS中String类型转换Date类型
- C++中string的用法大全
- C++中 string 的用法大全
- C++中 string 的用法大全
- C++中 string 的用法大全
- js中String方法 replace
- js中number类型转为string
- C#中 string.format方法使用大全
- string 用法大全
- String用法大全
- JavaScript中String类型的方法
- java 中类型转为String方法
- js string 函数大全
- String 类型的用法
- string类型常见用法
- 《深入理解Java虚拟机学习笔记之垃圾收集器与内存分配策略》
- Classpath resource not found when running as jar
- msm8916 camera driver添加新摄像头kernel hal修改
- linux系统中如何建立与删除软连接(方便快捷使用,大量节约时间)
- ssh允许root登录
- Js中String类型方法用法大全
- 机器视觉开源代码
- shell 双引号"" 单引号'' 反引号`` 的区别
- Oracle程序的优点和我缺点我是这样喜欢它的
- Java继承知识点总结(加面试题实例)
- 简单使用JTable读取数据库的表
- Rotate List leetcode java
- java中集合工具类Collections的使用
- 集训8.16最小生成树讲解