curtisp curtisp - 1 year ago 69
Javascript Question

Javascript concatenating string and variable to create url - but doesn't output "/" slashes

I am building HTML in JavaScript which is working fine however I have encountered something haven't seen before and am not finding obvious solution to get past this.

I am trying to create url by concatenating string and variable but it isn't outputting


I am building on the
variable which starts off creating a table:

var html = '<table class="table table-bordered">';
html += '<td><a href="' + columns[1] +'">' + columns[1] + '</a></td>';

However this outputs everything except the
slashes and adds
in place of

<a href="https:"" toptechstaffing"="">TopTechStaffing</href="https:>

Is this not possible in JavaScript? In other languages I have seen use of backslashes to escape foreslashes so they can be presented eg

What is the "common" way of doing this in JavaScript?

Edited to add:

variable was a string.

Answer Source

Something like this?

var html = "";

html += "<td><a href=\"" + columns[1] + "\">" + columns[1] + "</a></td>";
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download