嗨,我是 javascript 的新手,我正在努力让它工作。
基本上一切正常,但只要其中有任何空间,它就会中断。
它从数据库中提取一个文本字符串,这很好,直到有如下空格:
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);
现在,如果有这样的空间,那么它会中断:
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);