簡體   English   中英

刪除TinyMCE文本區域中的前導和尾隨空格

[英]Remove leading and trailing white spaces in TinyMCE text area

我正在嘗試刪除TinyMCE文本區域中的前導和尾隨空格。

var frontandbackremovedhere = tinyMCE.get('ID').getContent().trim();

我試過上面但不工作。我可以這樣做嗎

例如

如果我在編輯器中插入文字

    Hi,          


Regards


kez     

它將獲得html如下

<p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Hi,<br><br>Regards<br><br></p><p>kez &nbsp; &nbsp; &nbsp; &nbsp;</p>

我試圖像這樣刪除它

<p>Hi,&nbsp; &nbsp;<br><br>Regards<br><br></p><p>kez</p>

用這個

var frontandbackremovedhere=$.trim(tinyMCE.get('ID').getContent());
let editorContent = tinyMCE.get('ID').getContent({format:'raw'}).trim();
tinyMCE.get('ID').setContent(editorContent);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM