菜鸟javascript基础资料整理2

网络编程 发布日期:2024/10/13 浏览次数:1

正在浏览:菜鸟javascript基础资料整理2
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>
Windows上运行安卓你用过了吗
在去年的5月23日,借助Intel Bridge Technology以及Intel Celadon两项技术的驱动,Intel为PC用户带来了Android On Windows(AOW)平台,并携手国内软件公司腾讯共同推出了腾讯应用宝电脑版,将Windows与安卓两大生态进行了融合,PC的使用体验随即被带入到了一个全新的阶段。