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)

html有什么好方法获取当距离当期节点最近的指定元素?

场景:比如鼠标点击就会有光标,但是有的地方是不能点的,比如<div><span>123</span></div>,只能将光标放在span内部,不能放在span外部,div内部。就需要获取光标判断是否正确,不正确则获取最近的span标签然后聚焦就可以了。


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

1 Answer

0 votes
by (71.8m points)

点击的时候判断点击的元素是不是不想要聚焦的 如果是 把他换成input 不是就不换


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

...