HTML onselect 屬性
定義和用法
onselect
屬性在元素中的部分文字被選中後觸發。
適用範圍
onselect
屬性是 事件屬性 的一部分,可用於任何 HTML 元素。
元素 | 事件 |
---|---|
所有 HTML 元素 | onselect |
示例
Input 示例
在 <input> 元素中選中部分文字後執行 JavaScript
<input type="text" onselect="myFunction()" value="Hello world!">
自己動手試一試 »
瀏覽器支援
事件屬性 | |||||
---|---|---|---|---|---|
onselect | 是 | 是 | 是 | 是 | 是 |