The read function of jquery and the onload of JS in different ways to realize _jquery

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.