0

如果我在元素上使用工具提示和弹出 Twitter Bootstrap Javascript 组件,我如何确定哪个组件触发了“显示”事件?

例如:

$("#button").tooltip();
$("#button").popover();

$("#button").on("shown", function(event) {
    // I need to do some (flash) stuff that's specific to the popover content,
    // the shown event is fired for both the tooltip and popover but doesn't 
    // appear to include any useful information about the context of the event.

    // How do I determine if the popover component fired the event? The event.target
    // is useless because it points to #button.
    // The best I've come up with is to check if the element I'm interested in 
    // is visible but I'm assuming this will have issues if the popover component
    // is animated...
    if ($(".popover .thingy").is(':visible')) {
    }
});
4

1 回答 1

1

由于它使用 jQuery,我相信 event 表示的当前元素很简单:

this

或者,

$(this) // to do jQuery operations on it

如果要检查它是否可见:

if ($(this).is(":visible")) { ... }
于 2013-07-31T02:03:30.477 回答