javascript - how to detect if cursor text selection is visible on mobile browser? - Stack Overflow

I'm trying to add update the jQuery Terminal cursor position when text selection cursor is visible

I'm trying to add update the jQuery Terminal cursor position when text selection cursor is visible. This is my code:

function update_mobile_cursor() {
    if (is_mobile) {
        var selection = document.getSelection();
        console.log(selection);
        if (selection.anchorNode === selection.focusNode) {
            var range = selection.getRangeAt(0);
            console.log(range);
            self.position(range.endOffset);
        }
    }
}

But both selection and range exists even when the selection cursor is not visible. When I type something, the endOffset points into the last typed character.

Is there a way to detect the visibility of the selection cursor on a mobile Browser?

I have a testing webpage: .php when You press backspace it jumps to the beginning.

NOTE: that the function don't trigger when text selection is changed, I've asked about it here: Listen to cursor change on mobile browser

I test this with Chromium based Brave.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745630686a4637090.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信