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

后端 未结 2 1703
悲哀的现实
悲哀的现实 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 08:13

    There's nothing wrong with copying and pasting snippets of code, that's how most people start out and you will keep doing it until you get so familiar with the snippets that you paste that you'll start modifying bits and portions or even starting from scratch by yourself.

    For that particular piece of code, I don't really see anything wrong with copying it other than not relying on inline event handlers and unobtrusively adding the 'mousedown' with jQuery.

提交回复
热议问题