提示框 !DOCTYPE htmlhtmlheadmeta charset="utf-8"title滴答编程(dida100.com)/title/headbodyp点击按钮查看输入的对话框。/pbutton onclick="myFunction()"点我/buttonp id="demo"/pscriptfunction myFunction(){var x;var person=pr...
...
函数 !DOCTYPE htmlhtmlheadmeta charset="utf-8" title滴答编程(dida100.com)/title scriptfunction myFunction(){alert("你好,世界!");}/script/headbodybutton onclick="myFunction()"点我/buttonp当按钮点击后,一个函数将被执...
带有参数的函数 !DOCTYPE htmlhtmlhead meta charset="utf-8" title滴答编程(dida100.com)/title /headbodyp点击这个按钮,来调用带参数的函数。/pbutton onclick="myFunction('Harry Potter','Wizard')"点击这里/buttonscri...
带有参数的函数 2 !DOCTYPE htmlhtml head meta charset="utf-8" title滴答编程(dida100.com)/title script function myfunction(txt) { alert(txt);} /script /head body form input type="button" onclick="myfunction('Good Morning!')" value=...
返回值的函数 !DOCTYPE htmlhtmlhead meta charset="utf-8" title滴答编程(dida100.com)/title scriptfunction myFunction(){return ("Hello world!");}/script/headbodyscriptdocument.write(myFunction())/script/body/html 尝试一下...
带有参数并返回值的函数 !DOCTYPE htmlhtmlhead meta charset="utf-8" title滴答编程(dida100.com)/title /headbodyp本例调用的函数会执行一个计算,然后返回结果:/pp id="demo"/pscriptfunction myFunction(a,b){retu...
For 循环 !DOCTYPE htmlhtmlhead meta charset="utf-8" title滴答编程(dida100.com)/title /headbodyp单击按钮将代码块循环执行5次。/pbutton onclick="myFunction()"点我/buttonp id="demo"/pscriptfunction myFunction(){var x="",i;...
循环输出 HTML 标题 !DOCTYPE htmlhtmlhead meta charset="utf-8" title滴答编程(dida100.com)/title /headbodyp单击按钮将HTML标题设置从1到6的样式显示/pbutton onclick="myFunction()"点我/buttondiv id="demo"/divscriptfunc...
While 循环 !DOCTYPE htmlhtmlheadmeta charset="utf-8"title滴答编程(dida100.com)/title/headbodyp点击下面的按钮,只要 i 小于 5 就一直循环代码块。/pbutton onclick="myFunction()"点击这里/buttonp id="demo"/pscriptfu...