Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
3.9k views
in Technique[技术] by (71.8m points)

contenteditable 的一些问题

image.png
https://codepen.io/hellozdq/p...

使用contenteditable的时候会出现一些问题
1、进行删除的时候剩下最后一个标签元素的时候会删不了
像这样就删不了
image.png

2、有时候删完的时候会出现<br>标签
3、当点击标签的时候有没有办法让焦点显示在标签的前面或后面
image.png

请教下怎么处理这些问题?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

在前后各加一个空格

<div style="border:solid 1px #000;padding:10px;" contenteditable>
  &nbsp;
  <span contenteditable=false style="color:blue">{客户名称}</span>
  的
  <span contenteditable=false style="color:blue">{客户电话}</span>
  &nbsp;
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

2.1m questions

2.1m answers

60 comments

57.0k users

...