E. Skwarka E. Skwarka - 6 months ago 19
CSS Question

Using quotes within a javascript array and getting the result verbatim

So I have an array that looks like:

var typeArray = [
"'<span class="class">Text</span>'",

and im calling the array in code that looks like this:

var elem = document.getElementById("pHolderGen1");
var num = 151;

for(var i = 1; i <= num; i++) {
var d = document.createElement('div');
d.setAttribute('class', 'pfl');
d.innerHTML = '<p>'
+ typeArray[i-1] +

Now I know there is an issue in the array with my use of quotes around class; however when I change it to:

var typeArray = [
"'<span class="/"grass"/">Grass</span>'",

as an attempt to get rid of the qoute issue I'm having all it displays is "NaN."
When I actually run the code I want it to produce (in html):

<p><span class="class">Text</span></p>

So in short I'm looking for a way to fix this and I also want to know why it does this.

Pat Pat

Change "'<span class="class">Text</span>'" to "<span class='class'>Text</span>"