I want to insert different url's dynamically after checking a condition
Here's the pseudocode
If div.id = "abc" then
create url <a href="www.zzz.html"'>Cosmetics</a>');
Append url to div
else if div.id = "xyz" then
create url <a href="www.abc.html"'>LEather goods</a>');
Append url to div
else if div.id = "mno" then
create url <a href="www.kkk.html"'>Diapers</a>');
Append url to div
and so on.
How can I write this in JavaScript/jQUery. How to handle the code efficiently if there are 15 such If-Else conditions.
This code is not looking good
if $("#abc) then
var dynLink = $('<a href=zzz.html"'>Cosmetics</a>');
$("#abc").append(dynLink);
else if $("#xyz")
var dynLink = $('<a href=abc.html"'>LEather</a>');
$("#xyz").append(dynLink);
Thanks!