欢迎来到天天文库
浏览记录
ID:18207074
大小:154.00 KB
页数:23页
时间:2018-09-15
《javascript的方法和技巧》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、JavaScript就这么回事1:基础知识1创建脚本块1:2:JavaScriptcodegoeshere3:2隐藏脚本代码1:2:5:在不支持JavaScript的浏览器中将不执行相关代码3浏览器不支持的时候显示1:2:Hellotothenon-JavaScriptbrowser.3
2、:4链接外部脚本文件1:5注释脚本1://Thisisacomment2:document.write(“Hello”);//Thisisacomment3:/*4:Allofthis5:isacomment6:*/6输出到浏览器1:document.write(“Hello”);7定义变量1:varmyVariable=“somevalue”;8字符串相加1
3、:varmyString=“String1”+“String2”;9字符串搜索1:2:7:search方法指明是否存在相应的匹配。如果找到一个匹配,search方法将返回一个整数值,指明这个匹配距离字符串开始的偏移位置。如果没有找到匹
4、配,则返回-1。10字符串替换1:thisVar.replace(“Monday”,”Friday”);11格式化字串varmyVariable="Hellothere";document.write(myVariable.big()+"");document.write(myVariable.blink()+"");document.write(myVariable.bold()+"");document.write(myVariable
5、.fixed()+"");document.write(myVariable.fontcolor("red")+"");document.write(myVariable.fontsize("18pt")+"");document.write(myVariable.italics()+"");document.write(myVariable.small()+"");document.write(myVariable.strike()+"");document.writ
6、e(myVariable.sub()+"");document.write(myVariable.sup()+"");document.write(myVariable.toLowerCase()+"");document.write(myVariable.toUpperCase()+"");varfirstString="MyString";varfinalString=firstString.bold().toLowerCase().fontcolor("red");
7、:黑体,斜体,下划线,打字机体。12创建数组1:2:11:varmyArray=newArray(5);m
此文档下载收益归作者所有