我對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