javascript - grumble.js,jQuery 插件(气泡弹出窗口): how to make it not polute my document body with unremovable trash?

标签 javascript jquery html dom popup

我想在点击时显示一个弹出窗口。我希望很多人都处于泡沫之中。所以我创建了一个演示:here .但是那个Bubble generator plugin每次显示弹出窗口时,我都会在 DOM 中保留大量垃圾。好吧,所以我试着通过

        $('.grumble-text').remove();
        $('.grumble').remove();
        $('.grumble-button').remove();

但它以某种方式完全阻止了它=(那么如何更改 grumble-bubble popup plugin code 以使其保持 DOM 清洁或至少使插件独立于它创建的垃圾?

最佳答案

我最近更新了插件以更好地控制定位和 Angular 。更新还保留了提示,在元素上多次调用插件不会创建额外的剩余 DOM。

尝试更新到最新代码。下面的代码现在应该可以按预期工作。

var html = ''
    +'<a href="#me" target="_blank">Download me</a>'
    +'<br/>'
    +'<a href="#edit">Edit me</a>'
    +'<br/>'
    +'<a href="#delete">Delete me</a>';

var $grumble = $('#grumble3');

$grumble.mouseup(function(eventObj) {
    $grumble.grumble({
        text: html ,
        angle: (Math.random() * 360 + 150),
        distance: 30,
        hideOnClick: true,
        onShow: function() {
            $grumble.addClass("hilight");
        },
        onBeginHide: function() {
            $grumble.removeClass("hilight");
        }
    });
}).mousedown(function() {
    $grumble.addClass("hilight");
});

感谢您的关注。如果还有其他问题,请在 github 页面上将其作为错误提出。 https://github.com/jamescryer/grumble.js

关于javascript - grumble.js,jQuery 插件(气泡弹出窗口): how to make it not polute my document body with unremovable trash?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7949243/

相关文章:

javascript - JQuery 是否支持字典(键,值)集合?

javascript - 如何将span id传递给rails Controller ?

html - 如何使用影响表格一侧的单个连续渐变

javascript - 如何通过 jQuery/JavaScript 将 html 表格导出到 HTML 页面中的 excel 或 pdf?

javascript - 循环变量

javascript - 将 jinja2 url_for 设置为 getJSON 回调中的 href

javascript - Bootstrap Tour n.popover 不是一个函数

jquery 第一个子语法

javascript - 为什么我的功能只能在 Firefox 中使用?

javascript - 我想统计用户参与了多少问题