V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
november
V2EX  ›  问与答

有什么方法可以重设 contentEditable 的光标位置?

  •  
  •   november · Dec 7, 2022 · 559 views
    This topic created in 1247 days ago, the information mentioned may be changed or developed.
    最近做一个输入框需要在里面添加样式,用 contentEditable 属性,基本原理就是在替换输入框内容的同时,也把光标位置重设一次。

    但是问题来了,网上找的方案,都会在回车换行的时候出问题。

    想问下有相关经验的人,是如何处理回车换行的光标定位问题的?
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1003 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 18:44 · PVG 02:44 · LAX 11:44 · JFK 14:44
    ♥ Do have faith in what you're doing.