JSFiddle - React, Tailwind, and code Playground
by int32_t
HTML
<input ng-keydown="functionX($event);"
textselect="" ng-keypress="functionY($event);"
ng-keyup="loginKey($event);"
id="field123" class="username ng-isolate-scope"
type="text" ng-focus="setFocus($event);"
style="z-index: 1;" value=12345>
<pre>
</pre>
CSS
.username {
width: 360px;
position: absolute;
left: 0;
top: 0;
padding-left: 17px;
line-height: 50px;
color: #2a2a2a;
font-family: "Arial";
font-size: 16px;
text-align: left;
position: absolute;
}
pre {
margin-top: 60px;
border: 1px solid blue;
}
JavaScript
var elem = document.getElementById('field123');
elem.addEventListener('touchstart', function(e) {
log('target=' + e.target + ' elem=' + elem)
log('startSelection target: '+e.target.selectionStart);
log('endSelection target: '+e.target.selectionEnd);
log('startSelection elem: '+elem.selectionStart);
log('endSelection elem: '+elem.selectionEnd);
});
function log(mes) {
document.querySelector('pre').textContent += mes + '\n'
}