使用 qTip 操作原始元素
我的页面上有一堆 div,每个 div 都只有 class 属性。在 div 中有一些 span,它们被设置为在 qTip 的帮助下显示工具提示。
工具提示应包含三个项目:
- Up:锚点,应将 OuterDiv 向上移动(可能如下所示:在 jquery 中向上/向下移动)
- Down: 锚点,应该将 OuterDiv 向下移动
- 删除:锚点,应该删除调用 OuterDiv
到目前为止我的代码:
<body>
<div class="OuterDiv">
<div class="InnerDiv">
<span class="Position">Position 1</span>
</div>
</div>
<div class="OuterDiv">
<div class="InnerDiv">
<span class="Position">Position 2</span>
</div>
</div>
</body>
和脚本:
$(document).ready(function () {
var qTipContent = '<a href="javascript:void(0)" onclick="">↑</a> ';
qTipContent = qTipContent + '<a href="javascript:void(0)" onclick="">↓</a> ';
qTipContent = qTipContent + '<a href="javascript:void(0)" onclick="">X</a>';
$('.Position').each(function () {
$(this).qtip({
content: qTipContent,
hide: {
fixed: true
}
})
});
});
应该如何onclick
函数中的qTip内容是什么样子的?
I have a bunch of divs on my page and each of them has only the class attribute. In the divs there are some spans, which are set up to display a tooltip with the help of qTip.
The tooltip should contain three items:
- Up: anchor, which should move the OuterDiv up (probably something like this: move up/down in jquery)
- Down: anchor, which should move the OuterDiv down
- Delete: anchor, which should remove the calling OuterDiv
My code so far:
<body>
<div class="OuterDiv">
<div class="InnerDiv">
<span class="Position">Position 1</span>
</div>
</div>
<div class="OuterDiv">
<div class="InnerDiv">
<span class="Position">Position 2</span>
</div>
</div>
</body>
And scripts:
$(document).ready(function () {
var qTipContent = '<a href="javascript:void(0)" onclick="">↑</a> ';
qTipContent = qTipContent + '<a href="javascript:void(0)" onclick="">↓</a> ';
qTipContent = qTipContent + '<a href="javascript:void(0)" onclick="">X</a>';
$('.Position').each(function () {
$(this).qtip({
content: qTipContent,
hide: {
fixed: true
}
})
});
});
How should the onclick
function in the qTip content look like?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我的解决方案可以在这里找到 jsFiddle - 除了清理 qTipContent (真的很乱)之外,唯一真正的解决方案值得注意的补充是向锚点添加 id,并在添加 qTip 窗口时使用 qTip api 将绑定添加到每个锚点的单击事件。
My solution can be found at this jsFiddle - Besides cleaning up the qTipContent (was just really messy), the only real notable addition was adding ids to the anchors, and using the qTip api to add bindings to the click event for each anchor as the qTip window is added.