关注可了解更多的教程及排版技巧。问题或建议,请底部评论;
[如果你觉得对你有帮助,欢迎评论

前端点击事件之 < a>标签的点击触发以及自动触发的问题

a标签的点击事件,直接给a标签设置id,进而对a进行点击即可;
<a href="javascript:;" class="next-step btn mt50" id="submit" >提交预约</a>

 e("#submit").on("click",
        function() {
//执行业务逻辑
            // 禁用重复点击事件
            $("#submit").attr("disabled",true);
// ...
        });
等行内元素,并对行内元素进行id赋值,对a标签的自动点击实际上是对a标签内的行内元素进行自动触发,如;
//demo--JQ
<a href="javascript:;" class="next-step btn mt50" id="submit" ><span>自动提交预约</span></a>

 $(function()
    $("#submit").trigger("click");

}); 

//demo--JS
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
</head>
<script type="text/javascript"> 

function run(){
    document.getElementById("sp").click();
}
</script> 
<body onload="run()">
    <a href="https://www.baidu.com"><span id="sp">自动点击</span></a>
</body>
</html>

相关文章:

  • 2021-10-09
  • 2021-05-19
  • 2021-06-22
  • 2022-12-23
  • 2022-12-23
  • 2022-02-09
  • 2022-02-07
猜你喜欢
  • 2021-11-20
  • 2021-12-12
  • 2021-06-10
  • 2021-10-05
  • 2022-12-23
  • 2021-11-18
  • 2021-11-06
相关资源
相似解决方案