jquery popup需要知道哪个元素导致了该事件(jquery popup needs to know which element caused the event)

编程入门 行业动态 更新时间:2024-10-24 11:26:30
jquery popup需要知道哪个元素导致了该事件(jquery popup needs to know which element caused the event)

我有以下javascript使用qtip库来创建一个javascript弹出窗口。 我不确定如何访问单击集合中的li元素。 这可能吗? 我在下面的代码中添加了一个警告框,以帮助解释问题。 需要帮助请叫我! 非常感谢,

$('li').each(function () { $(this).qtip( { content: { text: 'test text', title: { text: true, button: '<img src="/Images/close.gif">' } }, position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle' }, adjust: { screen: true } }, show: { when: 'click', solo: true }, api: { beforeShow: function(index) { if(document.getElementById('basketCheck')) { alert('what LI caused this click?'); return false; } } }, hide: 'unfocus', style: { tip: true, border: { width: 0, radius: 4, }, width: 264, height: 195, title: { background: '#ffffff' }, lineHeight: '16px' } })

});

I have the following javascript that uses the qtip library for creating a javascript pop up. I'm not sure how to gain access to which li element within the collection was clicked. Is this possible? I've added an alert box within the code below to help explain the problem. Let me know if you need anything else! Many thanks,

$('li').each(function () { $(this).qtip( { content: { text: 'test text', title: { text: true, button: '<img src="/Images/close.gif">' } }, position: { corner: { target: 'rightMiddle', tooltip: 'leftMiddle' }, adjust: { screen: true } }, show: { when: 'click', solo: true }, api: { beforeShow: function(index) { if(document.getElementById('basketCheck')) { alert('what LI caused this click?'); return false; } } }, hide: 'unfocus', style: { tip: true, border: { width: 0, radius: 4, }, width: 264, height: 195, title: { background: '#ffffff' }, lineHeight: '16px' } })

});

最满意答案

触发元素在qTip实例的elements.target属性中可用。 反过来,该实例在beforeShow处理程序中与this绑定:

api: { beforeShow: function() { if(document.getElementById('basketCheck')) { // This <li> caused the click. var sourceElement = this.elements.target; return false; } } }

The triggering element is available in the elements.target property of the qTip instance. That instance, in turn, is bound to this in beforeShow handlers:

api: { beforeShow: function() { if(document.getElementById('basketCheck')) { // This <li> caused the click. var sourceElement = this.elements.target; return false; } } }

更多推荐

本文发布于:2023-08-07 20:18:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1466003.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:元素   事件   popup   jquery   caused

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!