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"