简单的js代码..

来源:互联网 发布:进销存加收银软件排行 编辑:程序博客网 时间:2024/05/16 14:46

从今天开始0基础学习javascript,有点html和php基础,我想学习这个不会太难的,我也不视频学习了,太浪费时间,是时候自己咀嚼点东西了,哈哈.

javascipt.html

window.onload=initAll;function initAll(){document.getElementById("Lincoln").onclick=saySomething;document.getElementById("Kenedy").onclick=saySomething;document.getElementById("Nixon").onclick=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.onload=initAll;function initAll(){document.getElementById("Lincoln").onclick=saySomething;document.getElementById("Kenedy").onclick=saySomething;document.getElementById("Nixon").onclick=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说不具备的.

原创粉丝点击