Get selected text on the page (not in a textarea) with jQuery

后端 未结 2 1710
悲哀的现实
悲哀的现实 2020-12-10 07:47

This plugin lets you grab text the user has selected in a textarea, and this site has non-jQuery-based instructions for grabbing text the user has selected outside of a text

2条回答
  •  难免孤独
    2020-12-10 07:55

    The reason it's hard to find a plug-in for this isn't that it isn't very "jQuery"ish. By that I mean that jQuery plugins normally operate on jQuery objects and the selection has nothing to do with any elements.

    Edit: I missed the fact you posted this link in your question but I'll leave it below for completeness since my version is formatted better (but otherwise identical). :)

    
     
    

提交回复
热议问题