Blogger Information
Blog 35
fans 0
comment 0
visits 16758
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
1.表单默认提交的三种方式2.this.target,currentTarget的区别
手机用户311660634
Original
349 people have browsed it
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <ul>
  11. <li></li>
  12. <li></li>
  13. <li></li>
  14. </ul>
  15. <!-- 1.在form属性中设置onsubmit的值为 return FALSE可以达到禁止按钮提交 -->
  16. <form action="" onsubmit="return false">
  17. <!--2. button 中的type属性改成button就可以达到禁止按钮提交 -->
  18. <button name="tijiao" type="button"></button>
  19. </form>
  20. <script>
  21. document.querySelector('ul').onclick = function(ev){
  22. // 这里的currentTarget指向的是UL
  23. ev.currentTarget
  24. // 这里的target指向的是UL下级的LI
  25. ev.target
  26. // this和currentTarget的值一样,永远指向的是添加的监听对象
  27. // 在最低一级中,target 和 currentTarget的值是一样的。target是触发对象,currentTarget是添加绑定的对象
  28. }
  29. document.forms.tijiao.onclick = function(ev){
  30. // 3.拿到按钮,禁用提交行为
  31. ev.preventDefault()
  32. }
  33. </script>
  34. </body>
  35. </html>
Correcting teacher:PHPzPHPz

Correction status:qualified

Teacher's comments:
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post