dynamically adding a class to parent container from a dynamically added container using jquery
<p>I have a method to dynamically add a container which is attached to the target container . When the action has been performed i removed the action container but now I have to add a class to parent container but problem is it is getting set (class name to parent container ) but it gets removed itself. For more clarification I am adding an sample code</p>

<pre><code>&lt;div class="main"&gt;
  &lt;ul&gt;
    &lt;li&gt;some contents&lt;/li&gt;
    ................
    ................
  &lt;/ul&gt;
  &lt;ul class="dynamic_container"&gt;
   &lt;li&gt;actions&lt;/li&gt;
   ................
  &lt;/ul&gt;
&lt;/div&gt;
</code></pre>

<p>dynamic_container is added when user mouseover the main class container and this get removed once action has been executed . But now it gets added(class name) but it gets removed too .
I believe this is basically because $(e.target) get removed ....</p>

<p>Any advice/suggestion will be appreciated . Thanks in advance.</p>

<p>edit :</p>

<p>$(e.target).parents('.main').addClass('current'); (this code does not able to add class to .main div) . This code is executed from ul.dynamic_container (which is added to the dom on mouseover on div.main)</p>

<p>edit 2:
jsfiddle link: this is the structure (not the actual code)</p>

<p><a href="http://jsfiddle.net/CASy6/" rel="nofollow">http://jsfiddle.net/CASy6/</a></p>
