JSFiddle - React, Tailwind, and code Playground
by termi
HTML
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<input type='text' id='hey' value='hello' />
<p>click to page to set selection[Start/End]</p>
<textarea>some text</textarea>
<p>try to click to textarea</p>
</body>
</html>
JavaScript
var a = document.getElementById('hey');
function selectAll() {
a.selectionStart = 0;
a.selectionEnd = a.value.length;
}
document.addEventListener('click', selectAll);