Luca S. Luca S. - 1 year ago 57
HTML Question

How do I put a link inside an array that is displayed through a function

Ok so I have a textbox where, depending on which button you click, text from an array is displayed

var Text= new Array();

function Anzeige(x) {
document.getElementById("Text").innerHTML = Text[x];
<input type="button" value="x" onclick="Anzeige(1)">
<input type="button" value="y" onclick="Anzeige(2)">
<input type="button" value="z" onclick="Anzeige(3)">
<div id="Anzeigefeld">
<div id="Text"></div>

So far so good, everything works as planned, but now I want to use a link like "
Text[1]="for more informations look <a style="color:blue;" href="insertlinkhere">here</a>
” and it just stops working (aka nothings happening when I click a button.

Help pls?

Answer Source

You need to escape occurance of " as \"

Text[1]="for more informations look <a style=\"color:blue;\" href=\"insertlinkhere\">here</a>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download