unexpected identifier: quick question
-
var tempDiv = "
";
divs.push(tempDiv);is this code valid in javascript? i'm getting error in chrome console that says unexpected identifier the error is on first line.
If that's the precise code you've got, and it hasn't been mangled by the site, then it's not valid Javascript. Nested quotes need to be escaped:
var tempDiv = "<div class=\"someClass\"></div>";
// Or:
var tempDiv = '<div class="someClass"></div>';You also need to remove the spaces around the
=
character for the string to be valid HTML.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer
-
If that's the precise code you've got, and it hasn't been mangled by the site, then it's not valid Javascript. Nested quotes need to be escaped:
var tempDiv = "<div class=\"someClass\"></div>";
// Or:
var tempDiv = '<div class="someClass"></div>';You also need to remove the spaces around the
=
character for the string to be valid HTML.
"These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer