在 contenteditable div 中的选定文本上添加跨度
我希望用户能够选择 div 中的文本并向其添加 。
示例代码 @ http://jsfiddle.net/SkDA8/1/
将鼠标悬停在 div 上并单击缺少图片来显示色样
感谢您的帮助!
PS
我希望它能在所有现代浏览器中工作。
I want the user to be able to select the text in the div and add the <span style="color: #ff3300;">
to it.
Example code @ http://jsfiddle.net/SkDA8/1/
Hover over to div and click on the missing picture to display the color-swatch
Thanks for your help!
PS
I want it to work in all modern browsers.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我正要回复你在 Rangy 小组上发表的有关此事的帖子,但我也会在这里回复。
这是可以使用
document.execCommand()
实现的一项任务:我已经为您的 jsfiddle 创建了更新:
I was about to respond to your post to the Rangy group about this, but I'll respond here too.
This is one task that is achievable using
document.execCommand()
:I've created an update to your jsfiddle: http://jsfiddle.net/timdown/SkDA8/3/
不太确定你想做什么。这是一个更新的 jsFiddle,它获取单击的彩色样本的值并更新标题颜色。
http://jsfiddle.net/SkDA8/4/
希望这会有所帮助。
鲍勃
Not exactly certain what you are trying to do. Here is an updated jsFiddle that gets the value of the colored swatch that is clicked and updates the header color.
http://jsfiddle.net/SkDA8/4/
Hope this helps.
Bob