从今天开始0基础学习javascript,有点html和php基础,我想学习这个不会太难的,我也不视频学习了,太浪费时间,是时候自己咀嚼点东西了,哈哈.
javascipt.html
window.οnlοad=initAll;
function initAll(){
document.getElementById("Lincoln").οnclick=saySomething;
document.getElementById("Kenedy").οnclick=saySomething;
document.getElementById("Nixon").οnclick=saySomething;
}
function saySomething(){
switch(this.id){
case "Lincoln":alert("four score and seven years ago");break;
case "Kenedy":alert("ask not what your country can do for you..");break;
case "Nixon":alert("I'm not a crook");break;
}
}
script09.js
window.οnlοad=initAll;
function initAll(){
document.getElementById("Lincoln").οnclick=saySomething;
document.getElementById("Kenedy").οnclick=saySomething;
document.getElementById("Nixon").οnclick=saySomething;
}
function saySomething(){
switch(this.id){
case "Lincoln":alert("four score and seven years ago");break;
case "Kenedy":alert("ask not what your country can do for you..");break;
case "Nixon":alert("I'm not a crook");break;
}
}
我是这么理解javascript的,javascript的和php具有计算的的功能(这是html所不具备的),但是同时他可以嵌套在html中这又是php说不具备的.