Jquery 在页面加载时而不是 onclick

标签 jquery onclick onload

我喜欢这个 jquery 脚本在页面加载时加载,而不是在单击时加载。 我更改了以下内容:

<script>
    $('.error').on('click', function(){
        $(this).notifyMe(
            'bottom', // Position
            'error', // Type
            'Lorem Ipsum Text', // Title
            'Lorem Ipsum is simply dummy text of the printing', // Description
            200 // Velocity of notification
        2000 // (optional) Time of delay to close automatically
        );
    });
</script>

至:

<script>
    $(document).ready(function() {
        $(this).notifyMe(
            'bottom', // Position
            'error', // Type
            'Lorem Ipsum Text', // Title
            'Lorem Ipsum is simply dummy text of the printing', // Description
            200 // Velocity of notification
        2000 // (optional) Time of delay to close automatically
        );
    });
</script>

但它不会加载通知程序。 它基于以下脚本:http://www.jqueryrain.com/?koLHvt8W

有人可以告诉我我做错了什么吗?

最佳答案

应该是:

$(document).ready(function () {
    $('.error').notifyMe(
        'bottom', // Position
    'error', // Type
    'Lorem Ipsum Text', // Title
    'Lorem Ipsum is simply dummy text of the printing', // Description
    200 // Velocity of notification
    2000 // (optional) Time of delay to close automatically
    );
});

关于Jquery 在页面加载时而不是 onclick,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27570458/

相关文章:

jquery - 如何在页面加载一段时间后淡出 div 的边框和背景颜色?

javascript - 每次加载/提交表单时值加 1

javascript - 如何仅在加载所有元素后才在头部加载Javascript

jquery - 当一个 VideoJS 实例启动时,如何暂停页面上所有正在播放的 VideoJS 实例?

javascript - 通过 href 链接到 JavaScript 函数

javascript - 如何从 Javascript 启动两个或多个自定义 URL 协议(protocol)

javascript - 下载选项表单的两个 onClick 事件

javascript - jqPlot 不在页面加载时呈现,但在选择选择列表中的项目时正常工作

javascript - 如何定位 svg 以及根据选择隐藏和显示 svg

javascript - 如何为 NetSuite 中的 HTML 元素提供 DOM 中的 ID?