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; } } }更多推荐
发布评论