<div class="codetitle"> <span><a style="CURSOR: pointer" data="47919" class="copybut" id="copybut47919" onclick="doCopy('code47919')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code47919"> <br> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>无标题文档</title> <br><script type="text/javascript" src="jquery-1.7.1.min.js"></script> <br><script type="text/javascript"> <BR>var sayHello=function(){ <BR>alert("Hello,World!"); <BR>} <br><br>$(function(){ <BR>sayHello(); <BR>$('option[value=0]').attr('selected','selected'); <BR>$('select').change(sayHello); <BR>}) <br><br></script> <br> <br> <br><select name="sel"> <br><option value="0">one</option> <br><option value="1">two</option> <br><option value="2">three</option> <br></select> <br> <br> <br> </div> <br>以上代码的功能实现了对一个函数的多处调用。值得注意的是,当函数作为其他函数的参数时和独立调用时,写法是有区别的,前者不用附加(),而后者必须加()。