javascript - 如何在页面完全加载之前禁用点击事件?

标签 javascript php jquery jquery-events

<分区>

我想在页面完全加载之前禁用点击事件。页面加载大约需要 45 秒,还取决于互联网速度。同时,加载的元素不应可点击。

那里有很多链接所以我只想禁用点击事件

最佳答案

document.ready中绑定(bind)事件,它将确保在加载所有 DOM 时绑定(bind)事件。您应该重新考虑页面占用过多时间的原因。

$(document).ready(function(){
    $('#button').click(function(){

    });   
});

While JavaScript provides the load event for executing code when a page is rendered, this event does not get triggered until all assets such as images have been completely received. In most cases, the script can be run as soon as the DOM hierarchy has been fully constructed. The handler passed to .ready() is guaranteed to be executed after the DOM is ready, so this is usually the best place to attach all other event handlers and run other jQuery code, jQuery doc.

关于javascript - 如何在页面完全加载之前禁用点击事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22059323/

相关文章:

PHP 依赖注入(inject) - Pimple 等。 - 为什么使用关联数组与 getter?

javascript - 如何使 js 函数通用以在我的表单上的任何地方工作? (干燥)

jquery .hide 使用 {visibility :hidden;} is there alternative using {display:none;}

javascript - 从Javascript的每个函数中中断

javascript - 输入 Unresolved 任务

php - 使用多个条件过滤 MySQL 查询

php - 如何让 w3school 的联系表给我发电子邮件?

javascript - Accordion 未显示在选项卡中?为什么?

javascript - 从 Javascript 中的查询字符串创建嵌套对象

javascript - 查询。使用延迟将 css 应用于具有类的每个元素