W3Schools.com

onselect Event

Event Object Reference Event Object

Example

Execute a JavaScript after some text has been selected in an <input> element:

<input type="text" onselect="showMsg() value="Hello world!" />

Try it yourself »

Definition and Usage

The onselect event occurs after some text has been selected in an element.

Syntax

In HTML:

<element onselect="SomeJavaScriptCode">

In JavaScript:

object.onselect="SomeJavaScriptCode"

Parameter Description
SomeJavaScriptCode Required. Specifies a JavaScript to be executed when the event occurs


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The onselect event is supported in all major browsers.


onselect is Supported by the Following HTML Tags:

<body>, <input type="file">, <input type="password">, <input type="text">, <keygen>, <textarea>

onselect is Supported by the Following JavaScript Objects:

Window


Event Object Reference Event Object
WEB HOSTING
Best Web Hosting
PHP MySQL Hosting
Best Hosting Coupons
UK Reseller Hosting
Cloud Hosting
Top Web Hosting
$7.95/mo SEO Hosting
Premium Website Design
WEB BUILDING
Download XML Editor
FREE Website BUILDER
Free Website Templates Free CSS Templates
Make Your Own Website
W3SCHOOLS EXAMS
Get Certified in:
HTML, CSS, JavaScript, XML, PHP, and ASP
W3SCHOOLS BOOKS
New Books:
HTML, CSS
JavaScript, and Ajax
STATISTICS
Browser Statistics
Browser OS
Browser Display
SHARE THIS PAGE