javascript - How can I bind events to the appended element? -
I tried to show an error message using jquery effect fadeTo and hide the message Tried
$ ("# sub_error"). Fadeto (200, 0.1, function () {$ ("#sub-panic") .HTML (error.joined ("
") .append (' & Lt; br / & gt; input type = button "name =" err_ok "id =" err_ok "value =" ok "& gt; ') .addClass (' subboxerror ') .Fedato (900,1) Click here (function () {$ ("# sub_error"). FadeOut ("slow");}); What do I do Can I help someone?
You
$ ("% s") and solve it. #er_ok "). Click (function () {$ ("# sub_error"). Fade ("slow");}); Call the function after creating element in the function and in the DOM.
Edit: This should be a complete solution:
$ ("#sub-panic"). Fidelo (200, 0.1, function () {$ ("# Sub-Terror"). HTML (Error.joined ("
") .append (' & Lt; br / & gt; input type = "button" name = "err_ok" id = "err_ok" value = "right">) .addClass ('subboxerror') .Fedato (900, 1 ); Bind Aventus ();}); Function Bind Avent () {$ ("# err_ok"). Click (function () {$ ("# sub_error"). FadeOut ("slow");}); } There is also a function that binds events that are created in the future.
Comments
Post a Comment