简体   繁体   中英

Remove leading and trailing white spaces in TinyMCE text area

I'm trying to remove leading and trailing white spaces in TinyMCE text area.

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

I tried above but not working.how can I do this

for example

If I inset following text in editor

    Hi,          


Regards


kez     

It will get the html as following

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

I'm trying to remove it like this

<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);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM