JavaScript 函数的使用技巧
1、最简单的函数流程。我们定义一个函数,再设计一个按钮,让访问者可以实现点击按钮就有函数调用出来。<html><head><script type="text/javascript">function 函数(){alert("天天快乐")}</script></head><body><form><input type="button" onclick="函数()" value="函数按钮"></form><p>只要点击按钮就会调用函数</p></body></html>

3、向一个函数传递两个不同的参数值的ja箪滹埘麽va 代码使用技巧。<html><head><script type="text/javascript">function 函数(变量){alert(变量)}</script></head><body><form><input type="button"onclick="函数('天天快乐')"value="百度"><input type="button"onclick="函数('好心情')"value="经验"></form><p>向同样的函数传递不同的参数值</p></body></html>

5、直接让函数返回一个参数值。<html><head><script type="text/javascript">function 函数(){return ("天天快乐")}</script></head><body><script type="text/javascript">document.write(函数())</script></body></html>

7、除法也是一样的!<html><head><script type="text/javascript">function 函数(a,b){return a/b}</script></head><body><script type="text/javascript">document.write(函数(4,2))document.write(函数(10,5))document.write(函数(12,6))</script></body></html>
