How to pass a dynamically generated ID to Jquery
<p>I'm using a nice <a href="http://www.planitworks.nl/en/jeegoocontext" rel="nofollow">Jquery context menu</a> which returns the ID of my element in the form </p>

<pre><code>$(context).attr('id')
</code></pre>

<p>and not in the form</p>

<pre><code>$(this).attr('id')
</code></pre>

<p>due to the fact that I'm using one single context menu for a large number of elements where each element has its unique ID. The context menu works perfectly as it executes the commands relative to the clicked element identified by its unique ID.</p>

<p>I use the context menu to write data to a MySQl db via $.get and this works too.</p>

<p>But now I would like to use the data I get back from $.get and use it with the .replaceWith method to change some text without refreshing the page:</p>

<pre><code>$.get("jq_get_go.php", { parameter2: $(this).attr('menuCommand'), id: $(context).attr('id') }, 
    function(data) {
        $(".ci_saremo").xxxxx.replaceWith('&lt;li class="Like ci_saremo" id="' + $(context).attr('id') + '"&gt;&lt;a href=""&gt;' + data + '&lt;/a&gt;&lt;/li&gt;');
    }
);
</code></pre>

<p>I don't understand what should I replace the xxxxx with to get the ID of my element that I know I have here</p>

<pre><code>$(context).attr('id')
</code></pre>

<p>Of course if I omit xxxxx and leave</p>

<pre><code>$(".ci_saremo").replaceWith('&lt;li class="Like ci_saremo" id="' + $(context).attr('id') + '"&gt;&lt;a href=""&gt;' + data + '&lt;/a&gt;&lt;/li&gt;');
</code></pre>

<p>every ".ci_saremo" text will be replaced. So I need to identify it by its ID. Basically, I don't understand how to chain/insert <code>$(context).attr('id')</code> in the above string.</p>
