开发者

how to add div tags to content on enter key instead of p tags

开发者 https://www.devze.com 2023-03-14 03:56 出处:网络
On enter key press in a conten开发者_运维知识库teditable iframe,<P> tags are appended. I want to stop appending that <P> tags and append <div> tags instead.

On enter key press in a conten开发者_运维知识库teditable iframe, <P> tags are appended. I want to stop appending that <P> tags and append <div> tags instead.

Any suggestions will be valuable


Put some Keyup event and replace it

$('.myEditable').keyup(function(){
   var sanitazed = $(this).text().replace(/<p[^<]*?>/g, '<div>').replace(/<\/p[^<]*?>/g, '</div>');
   $(this).text(sanitazed);
});
0

精彩评论

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

关注公众号