onselect 事件

事件對象參考手冊 事件對象

實例

當文本被選中時,執(zhí)行一段 Javascript代碼:

<input type="text" onselect="myFunction">

嘗試一下 ?

定義和用法

onselect 事件會在文本框中的文本被選中時發(fā)生。

語法

HTML 中:

<elementonselect="SomeJavaScriptCode">

JavaScript 中:

object.onselect=function(){SomeJavaScriptCode}

參數(shù) 描述
SomeJavaScriptCode 必需。規(guī)定該事件發(fā)生時執(zhí)行的 JavaScript。


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持 onselect 事件


onselect 在 HTML 中

onselect 屬性可用于: <input type="file">, <input type="password">, <input type="text">, <keygen>, 和 <textarea>.


事件對象參考手冊 事件對象