Firefox sets wrong caret position contentEditable with :before

前端 未结 3 632
南旧
南旧 2020-12-03 07:54

playground

This is a simplified version of my problem.
seems like I cannot put a positioned pseudo element inside a contentEditable and yet have the caret posi

3条回答
  •  清歌不尽
    2020-12-03 08:20

    For me this was only a problem when the box was empty. So I seeded it with a
    :

      $("[contenteditable='true']").on('focus', function(){
        var $this = $(this);
        $this.html( $this.html() + '
    ' ); // firefox hack }); $("[contenteditable='true']").on('blur', function(){ var $this = $(this); $this.text( $this.text().replace('<.*?>', '') ); });

    More info here: https://bugzilla.mozilla.org/show_bug.cgi?id=550434

提交回复
热议问题