the onload implementation of JS:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"Http://www.w3.org/TR/html4/loose.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
The use of the OnLoad method of <title>js </title>
<script type= "Text/javascript" >
Window.onload=function () {
var mylinks = document.getElementsByTagName ("a");
for (var i=0; i<mylinks.length; i++) {
Mylinks[i].onclick=function () {
Alert ("linked");
}
}
}
</script>
<body>
The use of the OnLoad method of <a href= "#" > Links 1</a><br/>
<a href= "#" > Links 2</a><br/>
<a href= "#" > Links 3</a><br/>
<a href= "#" > Links 4</a><br/>
<a href= "#" > Links 5</a><br/>
<a href= "#" > Links 6</a><br/>
</body>
The implementation of the Ready method of jquery:
Copy Code code as follows:
<! DOCTYPE HTML PUBLIC "-//w3c//dtd HTML 4.01 transitional//en"
"Http://www.w3.org/TR/html4/loose.dtd" >
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
The use of <title>ready method 2</title>
<script type= "Text/javascript" src= "Jquery-core/jquery-1.8.0.js" ></script>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("a"). Click (function () {
Alert ("Link up!");
});
});
</script>
<body>
The use of <a href= "#" > Links 1</a><br/>
<a href= "#" > Links 2</a><br/>
<a href= "#" > Links 3</a><br/>
<a href= "#" > Links 4</a><br/>
<a href= "#" > Links 5</a><br/>
<a href= "#" > Links 6</a><br/>
</body>