很少用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>

我对onselect和onchange事件的误解我对onselect和onchange事件的误解

相关文章:

  • 2022-12-23
  • 2021-12-15
  • 2022-01-05
  • 2021-12-25
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-09-14
  • 2022-02-08
  • 2022-12-23
  • 2021-09-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案