Inserting Element Based on a Condition
<p>I want to insert different url's dynamically after checking a condition</p>

<p>Here's the pseudocode</p>

<pre><code>If div.id = "abc" then
create url &lt;a href="www.zzz.html"'&gt;Cosmetics&lt;/a&gt;');
Append url to div

else if div.id = "xyz" then
create url &lt;a href="www.abc.html"'&gt;LEather goods&lt;/a&gt;');
Append url to div

else if div.id = "mno" then
create url &lt;a href="www.kkk.html"'&gt;Diapers&lt;/a&gt;');
Append url to div
</code></pre>

<p>and so on.</p>

<p>How can I write this in JavaScript/jQUery. How to handle the code efficiently if there are 15 such If-Else conditions.</p>

<p>This code is not looking good</p>

<pre><code>if $("#abc) then

 var dynLink = $('&lt;a href=zzz.html"'&gt;Cosmetics&lt;/a&gt;');
    $("#abc").append(dynLink);

else if $("#xyz")
 var dynLink = $('&lt;a href=abc.html"'&gt;LEather&lt;/a&gt;');
    $("#xyz").append(dynLink);
</code></pre>

<p>Thanks!</p>
