onselect Event
Definition and Usage
The onselect event occurs after the text in the element is selected.
The onselect event is mainly used for <input type="text"> or <textarea> elements.
Instance
Example 1
Execute JavaScript when text is selected:
<input type="text" onselect="myFunction()">
Example 2
Use the select() method of the HTML DOM Input Text object to select some content of the text field. When this happens, the onselect event is triggered, which triggers the alert function.
// Select the content of the text field function mySelectFunction() { document.getElementById("myText").select(); } // When the text in the text field is selected, prompt some text function myAlertFunction() { alert("You selected some text!"); }
Syntax
In HTML:
<element onselect="myScript">
In JavaScript:
object.onselect = function(){myScript};
In JavaScript, use the addEventListener() method:
object.addEventListener("select", myScript);
Comment:Internet Explorer 8 ਜਾਂ ਪੁਰਾਣੇ ਸ਼ਾਮਿਲ ਨਹੀਂ ਹੈ addEventListener() Method。
Technical Details
Bubble: | ਸਮਰਥਨ ਨਹੀਂ ਕੀਤਾ ਜਾਂਦਾ ਹੈ |
---|---|
ਰੱਦ ਕਰਨ ਯੋਗ: | ਸਮਰਥਨ ਨਹੀਂ ਕੀਤਾ ਜਾਂਦਾ ਹੈ |
Event Type: | ਜੇਕਰ ਯੂਜ਼ਰ ਇੰਟਰਫੇਸ ਤੋਂ ਬਣਾਇਆ ਗਿਆ ਹੈ ਤਾਂ,UiEvent。 Event。 |
ਸਮਰਥਿਤ HTML ਟੈਗਸ: | <input type="file">, <input type="password">, <input type="text"> ਅਤੇ <textarea> |
DOM ਵਰਜਨ: | ਲੈਵਲ 2 ਈਵੈਂਟ |
ਬਰਾਉਜ਼ਰ ਸਮਰਥਨ
ਈਵੈਂਟ | ਚਰਮੀ | IE | ਫਾਇਰਫਾਕਸ | ਸਫਾਰੀ | ਓਪੇਰਾ |
---|---|---|---|---|---|
onselect | ਸਮਰਥਨ | ਸਮਰਥਨ | ਸਮਰਥਨ | ਸਮਰਥਨ | ਸਮਰਥਨ |