javascript – Button to Select Text

I have developed a wordpress website, it has custom posts… My all custom posts are in collapsable…
I want to add a button below the post content… whether when user press that button my whole text of that particular collapsable must be selected.. so that user can copy it or share it… how can I made it possible.. I am attaching some screenshots for better understanding…

Screenshot-2021-01-12-at-2-06-08-PM

Screenshot-2021-01-12-at-2-06-34-PM

please help to make it possible…