Makes the selection equal to the current object.
Method of dom/TextRangedom/TextRange
Syntaxvar result = range.select();
Return Value
Returns an object of type DOM NodeDOM Node
Type: HRESULT
If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.
ExamplesWhen applied to a TextRange object, the select method causes the current object to be highlighted. The following function uses the findText method to set the current object to the text in the TextRange object. The function assumes an element that contains the text string "text here".
function TextRangeSelect() {
var r = document.body.createTextRange();
r.findText("text here");
r.select();
}
When applied to a controlRange collection, the select method produces a shaded rectangle around the elements in the controlRange. The following function uses the add method to set the current object to an element in the controlRange collection. The function assumes an element with an id of "aaa".
function ControlRangeSelect() {
var r = document.body.createControlRange();
r.add(document.all.aaa);
r.select();
}
Usage
Used to programmatically select/highlight text and/or controls in a web document.
Notes Remarks
This method causes the current object to be highlighted. When applied to a TextRange object, the select method causes the current object to be highlighted. The following function uses the findText method to set the current object to the text in the TextRange object. The function assumes an element that contains the text string "text here".
function TextRangeSelect() {
var r = document.body.createTextRange();
r.findText("text here");
r.select();
}
This method produces a shaded rectangle around the elements in the controlRange. When applied to a controlRange collection, the select method produces a shaded rectangle around the elements in the controlRange. The following function uses the add method to set the current object to an element in the controlRange collection. The function assumes an element with an id of "aaa".
function ControlRangeSelect() {
var r = document.body.createControlRange();
r.add(document.all.aaa);
r.select();
}
This feature might not be available on non-Microsoft Win32 platforms.
Syntax Standards informationMicrosoft Developer Network: [select Method Article]
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4