Possible Duplicate:
How do I break a string across more than one line of code in JavaScript?
Hi i am new to javascript and i struggling to get this to work.
Basically everything works fine, but as soon as there are any spaces within it, it breaks.
Its pulling from the database a text string, which is fine until there is a space like as follows:
var getHtml = '<div class="counterwrap"><div class="countertitle"><h1><?php echo $ublunderconstructioninfo->title ; ?></h1></div><div class="counter"><div class="counternumbers"><div id="counterdays"></div><p>Days</p></div><div class="counternumbers"><div id="counterhours"></div><p>Hours</p></div><div class="counternumbers"><div id="counterminutes"></div><p>Minutes</p></div><div class="counternumberslast"><div id="counterseconds"></div><p>Seconds</p></div></div><div class="countertext">this is where some text goes</div></div>';
$("body").html(getHtml);
Now if there is a space like this, then then it breaks:
var getHtml = '<div class="counterwrap"><div class="countertitle"><h1><?php echo $ublunderconstructioninfo->title ; ?></h1></div><div class="counter"><div class="counternumbers"><div id="counterdays"></div><p>Days</p></div><div class="counternumbers"><div id="counterhours"></div><p>Hours</p></div><div class="counternumbers"><div id="counterminutes"></div><p>Minutes</p></div><div class="counternumberslast"><div id="counterseconds"></div><p>Seconds</p></div></div><div class="countertext">this is where some text goes
but when there is a linebreak
like this it breaks
</div></div>';
$("body").html(getHtml);
" so the spaces will be shown on the page. – Display Name Aug 29 '12 at 14:00
– Robert Gouveia Aug 29 '12 at 14:08