<strong>js的onload实现</strong>: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="29276" class="copybut" id="copybut29276" onclick="doCopy('code29276')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code29276"> <br>BR>"http://www.w3.org/TR/html4/loose.dtd"> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>js的onload方法的使用</title> <br><script type="text/javascript"> <BR>window.onload=function(){ <BR>var myLinks = document.getElementsByTagName("a"); <BR>for(var i=0 ; i<myLinks.length; i++){ <BR>myLinks[i].onclick=function(){ <BR>alert("链接了"); <BR>} <BR>} <BR>} <BR></script> <br> <br> <br><h1>js的onload方法的使用</h1> <br><a href="#">链接1</a><br> <br><a href="#">链接2</a><br> <br><a href="#">链接3</a><br> <br><a href="#">链接4</a><br> <br><a href="#">链接5</a><br> <br><a href="#">链接6</a><br> <br> <br> <br> </div> <br><strong>jquery的ready方法的实现</strong>: <br><div class="codetitle"> <span><a style="CURSOR: pointer" data="20990" class="copybut" id="copybut20990" onclick="doCopy('code20990')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code20990"> <br>BR>"http://www.w3.org/TR/html4/loose.dtd"> <br> <br> <br><meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <br><title>ready方法的使用2</title> <br><script type="text/javascript" src="jquery-core/jquery-1.8.0.js"></script> <br><script type="text/javascript"> <BR>$(document).ready(function(){ <BR>$("a").click(function(){ <BR>alert("链接了!"); <BR>}); <BR>}); <BR></script> <br> <br> <br><h1>ready方法的使用2</h1> <br><a href="#">链接1</a><br> <br><a href="#">链接2</a><br> <br><a href="#">链接3</a><br> <br><a href="#">链接4</a><br> <br><a href="#">链接5</a><br> <br><a href="#">链接6</a><br> <br> <br> <br> </div>