JSFiddle - React, Tailwind, and code Playground

by booktu8

HTML

<div class="flex items-center">
  <input type="text" class="border border-gray-400 flex-1 p-2 mr-2" value="Full name" id="fullName" />
  <button id="edit" class="border-none underline">Edit1</button>
</div>

JavaScript

const fullNameEle = document.getElementById('fullName');
const editEle = document.getElementById('edit');

editEle.addEventListener('click', function(e) {
  fullNameEle.focus();
  const length = fullNameEle.value.length;
  fullNameEle.setSelectionRange(length, length-1);
});