我对onselect和onchange事件的误解


很少用onselect事件,今天我才发现onselect事件:当选择一段文字的时候触发。以前我一直以为onselect和onchange都是是<select><option></option></select>内option元素切换的时候触发。是我误解了onselect事件。

 1 <!doctype html>
 2 <html>
 3 <head>
 4 <meta charset="utf-8">
 5 <title>exercise</title>
 6 <style></style>
 7 <script>window.onload=function(){
 8     document.getElementById("iptExercise").onselect=function(){
 9         alert("select");    
10     }
11     document.getElementById("iptExercise").onchange=function(){
12         alert("change");    
13     }
14 }
15 </script>
16 </head>
17 <body>
18 <input type="input" value="exercise" id="iptExercise" name="iptExercise">
19 </body>
20 </html>


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM