JavaScript可以点击一个div? [英] Can javascript click a div?

查看:126
本文介绍了JavaScript可以点击一个div?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



例如,脚本可以刷新网页,直到div显示出来(包含内容),并且如果div是可点击的,让javascript单击它(或者只是按照链接,如果有的话)。 使用jquery的div>

使用$(window).load();在网页加载全部内容后,附加所有事件的功能。请参阅以下代码:此处您可以阅读 load();



小提琴

 < div id =yourDivId >< / DIV> 
$ b $(window).load(function(){
$(document).on('click',#yourDivId,function(){
// Some代码
});
});


Is it possible to make javascript click on a div when the div exists in the browser?

For example, the script could refresh a webpage until a div shows up (with content), and than if the div is clickable, let javascript click it (or just follow the link, if there is one).

解决方案

using jquery . use $(window).load(); function which attach all event after body load all content in web page . see below code : here you can read document of load();

working example on fiddle

 <div id="yourDivId"></div>    

  $(window).load(function () {
    $(document).on('click',"#yourDivId",function () {
         // Some code here
     });
 }); 

这篇关于JavaScript可以点击一个div?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆