<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><br><br><br><br><br><br><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> </div> <a href="#">連結1</a><br> <br><a href="#">連結2</a><br> <strong><a href="#">連結3</a><br> </strong><a href="#">連結4</a><br> <br><a href="#">連結5</a><br> <div class="codetitle"> <a href="#">連結6</a><br> <span> <a style="CURSOR: pointer" data="20990" class="copybut" id="copybut20990" onclick="doCopy('code20990')"> <u></u> </a></span>jquery的ready方法的實作</div>: <div class="codebody" id="code20990"> <br><br><br><br>複製程式碼<br><br><br> 程式碼如下:<br><br> <br><br> 程式碼如下:<br><br> <br><doc0pe html public transitional>"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>}); </script></doc0pe> </div> <h1>ready方法的使用2</h1> <a href="#">連結1</a><br> <a href="#">連結2</a><br> <a href="#">連結3</a><br> <a href="#">連結4</a><br> <a href="#">連結5</a><br> <a href="#">連結6</a><br>