HTML onselect 事件屬性
實例
當選取<input>元素中的文本後執行JavaScript:
<input type="text" onselect="showMsg() value="Hello world!">
嘗試一下»
瀏覽器支持
所有主流瀏覽器都支持onselect 事件屬性
定義和用法
onselect 屬性在選取元素文本後觸發。
onselect 屬性可使用於以下元素: <input type="file">, <input type="password">, <input type="text">, <keygen>, 和<textarea>。
HTML 4.01 與HTML5之間的差異
無。
語法
<elementonselect=" script ">
屬性值
值 | 描述 |
---|---|
script | 规定该onselect事件触发时执行的脚本。 |
HTML事件屬性