js代码|模拟点击某个ID(js 模拟点击)
时间:2021-03-24 17:26:57 阅读:1027
<script type="text/javascript"> setTimeout( function(){ $(function(){ $("#zshao").trigger("click"); });}, 3 * 1000 );//延迟3000毫米 </script> <span id="zshao">自动点击</span> <script src="https://cdn.staticfile.org/jquery/3.2.1/jquery.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/kaygb/kaygb@master/layer/layer.js"></script> <script> //弹出一个页面层 $('#kmb-blog').on('click', function() { layer.open({ type: 2, title: 'Zshao网络', shadeClose: true, shade: false, maxmin: true, //开启最大化最小化按钮 area: ['80%', '100%'], content: '//zshao.vip/' }); }); $('#zshao').on('click', function() { layer.open({ type: 2, title: '专属APP', shadeClose: true, shade: false, maxmin: true, //开启最大化最小化按钮 area: ['80%', '50%'], content: 'https://wwa.lanzous.com/b0eq3tkha' }); }); </script>
完整代码↑
---------------------
setTimeout( function(){ });}, 3 * 1000 );//延迟3000毫米
上面是延迟代码。
$(function(){ $("#zshao").trigger("click");
这个是模拟点击代码,请留意#zshao,这是某个id【id="zshao"】
发个其他用途的自动点击
<script src="http://apps.bdimg.com/libs/jquery/2.1.1/jquery.min.js"></script> <script> var count = 0; $(document).ready(function() { $("#dianji").click(function() { count++; if (count >= 2) window.location = "/index5.html" }) }); setInterval(function() { $("#dianji").trigger('click') }, 1000); </script> <div id="dianji"> </div>
两秒后点击id=dianji 自动跳转到index5.html
网友评论