Answers for "select() in javascript"

0

select() in javascript

// select() in javascript
// add below code to your javascript file
function selectText() {
  const input = document.getElementById('text-box');
  input.focus();
  input.select();
}

// add below code to your html file
<input type="text" id="text-box" size="20" value="Hello world!">
<button onclick="selectText()">Select text</button>
Posted by: Guest on January-02-2022

Code answers related to "select() in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language