How to select the text of a span on click?

前端 未结 4 2049
旧时难觅i
旧时难觅i 2021-01-31 18:19

I am looking for a way to select the text inside a span using jquery when the text is clicked on.

For example in the html snippet below, I want the text \"\\apples\\ora

4条回答
  •  情深已故
    2021-01-31 19:04

    You can use CSS to do this more easily than JS with style="user-select: all;"

    add cursor: pointer; so its obvious they can click...

    See code snippet:

    Fruit \\apples\oranges\pears

提交回复
热议问题