Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

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>
Source by developer.mozilla.org #
 
PREVIOUS NEXT
Tagged: #javascript
ADD COMMENT
Topic
Name
1+1 =