Introduction to jquery Ready (FN) event usage _jquery

Source: Internet
Author: User
1. Introduction to Events
(1) binding a function to be executed when the DOM is loaded ready to be queried and manipulated;
(2) Make sure that there is no registration function in the OnLoad event for the <body> element, otherwise the +$ (document) will not be triggered. Ready () event;
(3) You can use $ (document) indefinitely on the same page. Ready () event;
(4) The functions registered in it will be executed sequentially in accordance with the order (in the code).
2. Event format
$ (document). Ready (function () {
jquery Code
});
3. Example
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>ready (FN) event </title>
<script type= "Text/javascript" src= "Jquery-2.0.3.js" ></script>
<style type= "Text/css" >
body{
Background-color: #CCCCFF;
font-size:24px;
Font-weight:bold;
Text-align:center;
}
. body_div{
padding:20px 20px 20px 20px;
}
</style>
<script type= "Text/javascript" >
$ (document). Ready (function () {
$ ("input[type= ' Radio ']"). Click (function () {
var se = $ ("Input[name= ' Sex '][type= ' Radio ']:checked"). Val ();
if (se = = "male") {
Alert ("Male");
}
if (SE = = "female") {
Alert ("female");
}
});
});
</script>
<body>
<div class= "Body_div" >
<input type= "Radio" id= "male" name= "sex" value= "male"/> Male
<input type= "Radio" id= "female" name= "sex" value= "female"/> Female
</div>
</body>

4. The results are as follows:
(1) When choosing "Male"

(2) When choosing "Female"

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.