How to use HTML DOM Text select in JavaScript

In this article i am going to explain HTML DOM text select method.
  • 1819

HTML DOM Text select method

The text object select method is used to select the content of a text field.

Syntax of text select method

textobject.select()


Browser support

The select method  is supported in all major browser.

Example of text select method

<!DOCTYPE html>

<html>

<head>

<script type="text/javascript">

    function TextSelFunction() {

        document.getElementById("data").select();

    }

</script>

</head>

<body>

<form>

Value <input type="text" id="data" value="Select Me" />

</form>

<button type="button" onclick="TextSelFunction()">Click Here</button>

</body>

</html>

Output:

text select new meth.jpg

You may also want to read these related articles :here

Ask Your Question 

Got a programming related question? You may want to post your question here

Programming Answers here

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.