jquery - Attach event to elements from ajax call -


I am trying to add a show event in a set of incoming divas in the form of an AJAX response, the original Setup looks like this:

  call - & gt; Ajax Success - & gt; 
1 "& gt; Show additional content & lt; / a

and so on.

I tried to add the click function on each link and send it to each div Show function like this:

  $ (function () {var foreachi D = 0; $ .jax ({.... success: function (html) {$ ('[id = "ShowEdgeant -"]). Each (function () {var Foreachid = foreachid + 1; $ (document) ). ('Click', '#Showaved content' '++++++++++++++++ foreachid .show ();});});  

Here's the problem?

Here's how you want to add an event listener: / P>

  $ (function () {$ (document) .on ('click', 'div [id ^ = "showaddcontent-"]', function () {Var foreachid = this.id. Split ('-'). Pop (); $ ("#hiddendiv -" + foreachid). Show ();}); $ AJAX ({// .... success: function (html) {// get data and add devices for DOM}});});  

Comments