I would like to retrieve the selection in a textarea when I click of a button/link.
$(el).on('click', function() {
console.log(window.getSelection().toString())
})
I got this, but it returns nothing. And I think the problem is because when I click on the button, the selection will dissapear. So of course is returns nothing then.
How would I fix this? Is there any way that I can click on the button and the selection will stay the same?