开发者

I need to have the <p></p> removed from TinyMCE

开发者 https://www.devze.com 2023-03-11 16:57 出处:网络
I need to have the <p></p> that开发者_JAVA百科 are automatically added by TinyMCE at the very beginning and the end removed.

I need to have the <p></p> that开发者_JAVA百科 are automatically added by TinyMCE at the very beginning and the end removed.

How?

Thanks.


I found http://tinymce.moxiecode.com/wiki.php/TinyMCE_FAQ#Select_if_default_text.2C_then_delete_when_typing_starts.3F , you may want to take a look at that.

You could use javascript (jquery) and do something like

var contents = $('.tiny-mce-text p').innerHTML;
$('.tiny-mce-text p').remove();
$('.tiny-mce-text').innerHTML(contents);

Or you could use PHP (or any other serverside script) to remove it, with a regular expression.

$text = preg_replace('^<p>', '', $text);
$text = preg_replace('</p>$', '', $text);

http://php.net/manual/en/function.preg-replace.php
This helps write regular expressions: http://gskinner.com/RegExr/

Good luck.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号