HTML onselect 事件屬性
示例
在 <input> 元素中選擇部分文字後執行 JavaScript
<input type="text" onselect="myFunction()" value="Hello world!">
自己動手試一試 »
定義和用法
onselect 屬性在元素中的部分文字被選中後觸發。
瀏覽器支援
| 事件屬性 | |||||
|---|---|---|---|---|---|
| onselect | 是 | 是 | 是 | 是 | 是 |
語法
<element onselect="script">
屬性值
| 值 | 描述 |
|---|---|
| script | onselect 時要執行的指令碼 |
技術詳情
| 支援的 HTML 標籤 | <input type="file">, <input type="password">, <input type="text">, and <textarea> |
|---|
相關頁面
HTML DOM 參考:onselect 事件
❮ HTML 事件屬性