Use Javascript to get the Sentence of a Clicked Word

后端 未结 5 2078
甜味超标
甜味超标 2021-02-05 21:37

This is a problem I\'m running into and I\'m not quite sure how to approach it.

Say I have a paragraph:

\"This is a test paragraph. I love cats. Please a         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-05 22:04

    I suggest you take a look at Selection and ranges in JavaScript.

    There is not method parse, which can get you the current selected setence, so you have to code that on your own...

    A Javascript library for getting the Selection Rang cross browser based is Rangy.

提交回复
热议问题