Inserting a text where cursor is using Javascript/jquery

前端 未结 13 2674
盖世英雄少女心
盖世英雄少女心 2020-11-22 03:58

I have a page with a lot of textboxes. When someone clicks a link, i want a word or two to be inserted where the cursor is, or appended to the textbox which has the focus.<

13条回答
  •  鱼传尺愫
    2020-11-22 04:29

    you can only focus required textbox an insert the text there. there is no way to find out where focus is AFAIK (maybe interating over all DOM nodes?).

    check this stackoverflow - it has a solution for you: How do I find out which DOM element has the focus?

提交回复
热议问题