Use Javascript to get the Sentence of a Clicked Word

后端 未结 5 2077
甜味超标
甜味超标 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 21:58

    1. Match the sentences. You can use a regex along the lines of /[^!.?]+[!.?]/g for this.
    2. Replace each sentence with a wrapping span that has a click event to alert the entire span.

提交回复
热议问题