Js file assume the current page in the following functions:
function A(){ function B(); } function B(){ $(document).on("click","#元素id",function(){ dosomething……; }); }
A processing function is a function of binding the onclick a button;
So after each button click function triggers A, B will result in the execution of the function, then $ ( "# element id") This element will bind a click event.
If after repeatedly A trigger function, resulting in $ ( "# element id") bind the click event several times above,
Then click $ ( "# element id") and they will find a logical Click event of the elements above is executed multiple times, which led to a page Caton, resubmit the form and so on.
To avoid this, you need to use when on the binding function uses function off before unbundling. The following wording:
$(document).off("click").on("click","#元素id",function(){ dosomething……; });
So can avoid the click event bound to the logical elements repeated multiple times.