需要了解的HTML知识
标签 table,tr,th,td
用循环进行重复操作
for(;;){}
javascript字符串
在javascript中,第一个字符在位置0上。cat,c在位置0上,a在位置1上,t在位置2上,所有其他字符串方法都是基于0的,在检查cat的length时,才会看到3这个值。
将值传递给函数
function abc(temp) function abc(temp1,temp2)
探测对象
window.onload = newCard;
function newCard{
if(document.getElementById){
for(var i =0;i<24;i++){
setSquare(i);
}
}
else{
alert("Sorry,your browser doesn't support this script");
}
}
function setSquare(thisSquare){
var currSquare = "square" + thisSquare;
var newNum = Math.floor(Math.radom() * 75) + 1;
document.getElementById(currSquare).inerHTML = newNum;
}
处理数组
var newCars = new Array(3);
var newCars = new Array("string1","string2","string3") newCars[0]
有返回值的函数
function getNewNum(){
return Math.floor(Math.random() * 15);
}
do/while循环
do{....}
while();
调用js脚本定义
document.getElementById("reoad").onclick = anotherCard
function anotherCard(){...}
使用多级条件
switch(this.value){
case "Lincoln":
alert("Four score and seven years ago....");
break;
case "Kennedy":
alert("Ask not what your country can do for you...");
break;
case "Nixon":
alert("I am not a crook!");
break;
default:
}
错误处理
window.onload = initAll;
function initAll(){
var ans = prompt("Enter a number","");
try{
if(!ans||isNaN(ans)||ans<0){
throw new Error("Not a valid number");
}
alert("The square root of " + ans +" is "+ Math.sqrt(ans));
}
catch(errMsg){
alert(errMsg.message);
}
}
本文介绍了HTML的基本元素如table、tr等,并深入探讨了JavaScript的基础知识,包括字符串处理、函数定义与调用、数组操作及错误处理等内容。
992

被折叠的 条评论
为什么被折叠?



