如何使span标签不可删除? [英] How can I make a span tag un-deletable?

查看:206
本文介绍了如何使span标签不可删除?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使span标签在"contenteditable" div中不可删除:

I'm attempting to make a span tag un-deletable inside a 'contenteditable' div:

<div contenteditable>Editable <span contenteditable="false">Read Only</span></div>

只读跨度确实是只读的,但是我可以通过按一次Delete键来删除整个跨度.有没有一种属性方法可以告诉跨度它不可删除?

The read only span is indeed read only, but I can delete the whole span with a single delete press. Is there an attribute way to tell the span that it is not deletable?

推荐答案

所以我想出了最简单的最佳解决方案.不需要内容可编辑div.仅有几个内容可编辑跨度.

So I figured out the best solution for me, very simple. A content editable div in not needed. Just a a few content editable spans.

            <div>
                <span contenteditable="true">
                    Editable text here.
                </span>
                <span contenteditable="false" style="font-weight: bold">
                    READ ONLY VALUES
                </span>
                <span contenteditable="true">
                    Edit more stuff here 
                </span>
             </div>

这篇关于如何使span标签不可删除?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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