html - How to add Hyperlink in javascript var? -
i've leraned js few days
as topic want put several hyperlinks in var
var aaa = [ 'www.google.com', 'www.yahoo.com', 'www.facebook.com']; $('#showlink').text(aaa[2]);
and "www.yahoo.com" link show in html,it's url
<div id="showlink"> </div>
how can that?
you use jquery .html() function instead of .text() allows dynamically update html, so;
$('#showlink').html('<a href="' + aaa[2] + '">' + aaa[2] + '</a>');
or, can append div with:
$('#showlink').append('<a href="' + aaa[2] + '">' + aaa[2] + '</a>');
Comments
Post a Comment