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

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -