1。 //使用变量的属性 <script type="text/javascript"> var txt="Hello World!" document.write(txt.length) </script> 2。 //把字符串中的所有字母都被转化为大写字母。 <script type="text/javascript"> var str="Hello world!" document.write(str.toUpperCase()) </script> 3。 //js中个变量添加超链接 <script type="text/javascript"> var txt="Hello World!" document.write("<p>超链接为: " + txt.link("http://www.w3school.com.cn") + "</p>") </script> 4。 //indexOf方法(定位字符串中某一个指定的字符首次出现的位置。如果没有查到返回-1,区分大小写) <script type="text/javascript"> var str="Hello world!" document.write(str.indexOf("Hello") + "<br />") //1 document.write(str.indexOf("World") + "<br />") //-1 document.write(str.indexOf("world")) //6 </script> 5。 //match() 方法 //使用 match() 来查找字符串中特定的字符,并且如果找到的话,则返回这个字符。 <script type="text/javascript"> var str="Hello world!" document.write(str.match("world") + "<br />") //world document.write(str.match("World") + "<br />") //null document.write(str.match("worlld") + "<br />") //null document.write(str.match("world!")) //world! </script> 6。 //replace() 方法在字符串中用某些字符替换另一些字符。 var str="Visit Microsoft!" document.write(str.replace("Microsoft","W3School")) 7. //合并两个数组 <script type="text/javascript"> var arr = new Array(3) arr[0] = "George" arr[1] = "John" arr[2] = "Thomas" var arr2 = new Array(3) arr2[0] = "James" arr2[1] = "Adrew" arr2[2] = "Martin" document.write(arr.concat(arr2)) </script>
推荐阅读
关于Ext中form移除textfield方法:hide(),setVisible(false),remove()
问题:当使用hide()方法和setvisible(false)方法去除items的中间(见过很多例子移除的都是尾部表单)表单后,原form验证无效 解决办法:使用remove(id)方法移除表单,可得到有效的form 原因:未知,希望大家补充 补>>>详细阅读
本文标题:菜鸟javascript基础资料整理2
地址:http://www.17bianji.com/kaifa2/JS/25262.html
1/2 1