Create tooltip at cursor position in text area with jQuery

后端 未结 2 725
陌清茗
陌清茗 2021-01-18 11:59

I\'m trying to create a tooltip above the input caret in a text area. This would be easy if I could get the x,y coordinates of the caret in the text area, however I\'ve been

2条回答
  •  梦谈多话
    2021-01-18 12:42

    Why does the tooltip have to be at the caret? Why not position it above (or somewhere around) the textarea? Here is a demo of what I mean.

    $('textarea').keyup(function(e) {
        switch (e.which) {
            // @ symbol
        case 50:
            makeTooltip(e, 'you typed in an at symbol');
            break;
        }
    });
    

提交回复
热议问题