<input> 要素内で、あるテキストが選択された後に JavaScript を実行します:
<input type="text" onselect="myFunction()" value="Hello world!">
Try it Yourself ❯
onselect 属性は、要素内であるテキストが選択された後に発火します。
| イベント属性 | |||||
|---|---|---|---|---|---|
| onselect | Yes | Yes | Yes | Yes | Yes |
なし。
<element onselect="script">
| 値 | 説明 |
|---|---|
| script | script は onselect で実行される |
| サポートする HTML タグ: | <input type="file">, <input type="password">, <input type="text">, <keygen>, and <textarea> |
|---|
HTML DOM リファレンス:onselect イベント
HTML イベント属性