I've come across a piece of code that allows me to select the text in a div whenever a user clicks on it:
<table>
<tr>
<td>
<div contenteditable onClick="document.execCommand('selectAll',false,null)">I'm editable</div>
</td>
</tr>
<tr>
<td>
<div contenteditable>I'm also editable</div>
</td>
</tr>
<tr>
<td>I'm not editable</td>
</tr>
</table>
Unfortunately, I have discovered that document.execCommand
has been deprecated according to this source. I am now looking for a suitable alternative. How can I make this change?