JSFiddle - React, Tailwind, and code Playground
HTML
<!DOCTYPE html>
<html>
<head>
<title>Select all</title>
<script type="text/javascript">
var text;
var log;
function select()
{
text.select();
log.innerHTML += ' - select';
}
window.onload = function() {
text = document.getElementById('text');
log = document.getElementById('log');
log.innerHTML = 'start';
text.onfocus = select;
}
</script>
</head>
<body>
<input type="text" id="text" readonly="readonly" value="hello, world">
<div id="log">
</div>
</body>
</html>