JQuery binds a click event to an element for multiple executions. jqueryclick
Original binding method:
$("#sdfsd").on("click",function(e){ ***** });
This method will only add new methods in the original click method;
Solution: Change the binding method:
$("#sdfsd").unbind("click").click(function(e){ ***** });
Unbind the click method bound to the element before binding the new click Method
The dynamically generated element of jquery automatically executes a click event.
<Script type = "text/javascript" src = "jquery-1.7.2.min.js"> </script>
<Script type = "text/javascript">
$ (Document). ready (function (){
$ (". D"). live ("click", function (){
Alert ("auto click link clicked! ");
});
$ ("# X"). append ("<a class = 'D' href = '#'> click automatically! </A> ");;
$ (". D"). click ();
});
</Script>
<Div id = "x">
</Div>
Pay attention to use live binding. After dynamically generated objects are generated, click
Why does the html element button added by jquery not execute the click Event bound to the class style?
The input and button generated when you add more rows are dynamically generated, so you cannot use click. You need to use live (live is not recommended for Versions later than jquery 1.7.2) or on
Set
$ (". SubmitBtn"). click (function (){
Change
$ (". SubmitBtn"). live ('click', function (){
Or
$ (". SubmitBtn"). on ('click', function (){
Remember, if the elements do not exist during page initialization, but are dynamically generated on the page, perform operations on these elements, such as click, blur, keyup, change ...., use on
. On ('click', function
. On ('blur', function
. On ('keyup', function
....