2014-01-12 22 views
0

我有一个范围,并且该范围内容可编辑。所以,让我们说...在跨度中......你写。获取值后保持空格不变

Hello, 
My name is Ari. 

当我让程序得到跨度文字和提醒,它提醒:

"Hello,My name is Ari." 

如何获得它,所以它保持距离,不然我放在缩进内容可编辑范围,当它打印出来。换句话说,我怎么得到它,所以我的计划吐出

Hello, 
My name is Ari. 

相反的:

Hello,My name is Ari. 

下面是HTML:

<span id="thirdspan" contenteditable="true">Write context text here:</span> 

这里是CSS:

谢谢!

+1

你是如何提醒从跨度的文本?向我们展示你的JS。 – George

回答

0

尝试这个

<span class="output">Output Formatted Content</span> <div id="thirdspan" contenteditable="true" class="stuff" >Write context text here:</div>

$(document).ready(function(){ 
    $('span.output').click(function(){ 
     alert($('.stuff').html()); 
    }); 
    });