JavaScript document.execCommand()拥有自己的标签 [英] JavaScript document.execCommand() own tags

查看:462
本文介绍了JavaScript document.execCommand()拥有自己的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现一些非常有趣! execCommand函数应用了许多有用的功能。但是有可能使用OWN包装?像:

  document.execCommand(styleWithCSS,false,< span class ='own-class'> ); 

我找到的所有相关内容都很旧......所以也许你们其中一个人知道一个好的解决方法或者其他什么。

解决方案

感谢dandavis。

以下作品非常好:

  document.execCommand(insertHTML,false,< span class ='own-class'>+ document.getSelection()+ < /跨度> 中); 


I've found some really interesting! The execCommand function applies many useful features. But is it possible to work with OWN wraps? Like:

document.execCommand("styleWithCSS", false, "<span class='own-class'>");

Everything related i've found was pretty old… so maybe one of you knows a good workaround or something.

解决方案

Thanks to dandavis.

The following works very well:

document.execCommand("insertHTML", false, "<span class='own-class'>"+ document.getSelection()+"</span>");

这篇关于JavaScript document.execCommand()拥有自己的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆