How to select all text in HTML input text using JavaScript

2 Answers

0 votes
<input id="iid" value="text text text" />
<button id="bid">Select Text</button>
const input = document.getElementById("iid");
const btn = document.getElementById("bid");

btn.addEventListener("click",()=>{
   input.select(); 
})

  
    
    
/*
run:

    
*/

 



answered Jun 26, 2021 by avibootz
0 votes
<input id="iid" value="text text text" onclick="this.select()" />

 



answered Jun 26, 2021 by avibootz
...