JavaScript就這么回事(JS基础知识整理).docxVIP

  • 3
  • 0
  • 约1.47万字
  • 约 20页
  • 2016-12-06 发布于重庆
  • 举报

JavaScript就這么回事(JS基础知识整理).docx

JavaScript就這么回事(JS基础知识整理)

1 创建脚本块引用内容程序代码script language=”JavaScript”JavaScript 代码写在这里面/script2 隐藏脚本代码引用内容程序代码script language=”JavaScript”!--document.write(“Hello”);// --/script在不支持JavaScript的浏览器中将不执行相关代码3 浏览器不支持的时候显示引用内容程序代码noscriptHello to the non-JavaScript browser./noscript4 链接外部脚本文件引用内容程序代码script language=”JavaScript” src=/”filename.js”/script5 注释脚本引用内容程序代码// This is a commentdocument.write(“Hello”); // This is a comment/*All of thisis a comment*/6 输出到浏览器引用内容程序代码document.write(“strongHello/strong”);7 定义变量引用内容程序代码var myVariable = “some value”;8 字符串相加引用内容程序代码var myString = “String1” + “String2”;9 字符串搜索引用内容程序代码script language=”JavaScript”!--var myVariable = “Hello there”;var therePlace = myVariable.search(“there”);document.write(therePlace);// --/script10 字符串替换引用内容程序代码thisVar.replace(“Monday”,”Friday”);11 格式化字串引用内容程序代码script language=”JavaScript”!--var myVariable = “Hello there”;document.write(myVariable.big() + “br”);document.write(myVariable.blink() + “br”);document.write(myVariable.bold() + “br”);document.write(myVariable.fixed() + “br”);document.write(myVariable.fontcolor(“red”) + “br”);document.write(myVariable.fontsize(“18pt”) + “br”);document.write(myVariable.italics() + “br”);document.write(myVariable.small() + “br”);document.write(myVariable.strike() + “br”);document.write(myVariable.sub() + “br”);document.write(myVariable.sup() + “br”);document.write(myVariable.toLowerCase() + “br”);document.write(myVariable.toUpperCase() + “br”);var firstString = “My String”;var finalString = firstString.bold().toLowerCase().fontcolor(“red”);// --/script12 创建数组引用内容程序代码script language=”JavaScript”!--var myArray = new Array(5);myArray[0] = “First Entry”;myArray[1] = “Second Entry”;myArray[2] = “Third Entry”;myArray[3] = “Fourth Entry”;myArray[4] = “Fifth Entry”;var anotherArray = new Array(“First Entry”,”Second Entry”,”Third Entry”,”Fourth Entry”,”Fifth Entry”);// --/script13 数组排序引用内容程序代码script language=”JavaScript”!--var myArray = new Array(5);myArray[0] = “z”;myArray[1] = “c”;myArray[2] = “d”;my

文档评论(0)

1亿VIP精品文档

相关文档