The click events bound to jquery do not take effect. Many of you have encountered this problem. Let's solve it for you, if you want to bind a click event to jquery, you can refer to the following. The Code is as follows:
1. html:
Method functions referenced by 2.html in test. js:
The Code is as follows:
$ ("# Ceshisub"). bind ("click", function (){
Var a = 1;
A + = 1;
Alert ("ceshisub ");
});
The problem occurs when the click event button on the page does not respond, opening the js debugging window at var a = 1; the breakpoint hit by this line does not come in.
The solution is:
1. Add loading events to the above js functions:
The added code is as follows:
The Code is as follows:
$ (Function (){
$ ("# Ceshisub"). bind ("click", function (){
Var a = 1;
A + = 1;
Alert ("ceshisub ");
});
});
In this way, the binding event takes effect.
There are three js loading functions, except for the preceding
The Code is as follows:
$ (Function (){
Alert ("1st methods. ");
});
There are two other methods:
The Code is as follows:
Window. onload = function (){
Alert ("2nd methods. ");
}
$ (Document). ready (function (){
Alert ("3rd methods. ");
});
2. If the js loading function is not used to initialize the binding event, there is another method:
The js statement will be referenced