JSFiddle - React, Tailwind, and code Playground

by jonigiuro

HTML

When you click in the input, I would like to select all the numbers.<br />
But if you click between 2 numbers, the selected is canceled by the typing cursor.<br /> Anyway to avoid that?
<br />
<input type="text" class="class-focusin" value="4578" />
<br /><br />
Regular input<br />
<input type="text" class="class-not-focusin" value="457887" /

JavaScript

var has_focus = false;
$('.class-focusin').click(function(e) {
    if(!has_focus) {
        $(this).select();
        has_focus = true;
    }
 });

$('.class-focusin').blur(function(e) {
   has_focus = false; 
});