第二次单击自定义工具提示时,绝对位置跨度消失

发布于 2024-12-18 08:28:02 字数 877 浏览 6 评论 0原文

检查代码。

<li>one <a href="#" class="opt">delete</a>
        <div class="popup">
            <span class="tip"></span><a href="#" class="btn">deletebutton</a></div>
    </li>

用于隐藏/显示 div.popup 的代码

$('.opt').live('click', function(e) {
    e.preventDefault();
    $(".popup").slideUp();
    $(this).closest("li").find(".popup").stop(true, false).slideToggle();
});

单击删除以打开每个 div.popup,但第二次单击打开的 div.popup 会使span.tip 消失。不刷新页面就不再出现。

$(".popup").slideUp();

我发现问题是由于这段代码造成的。我使用此代码在单击任何删除锚点时隐藏所有其他打开的 .popup 。我是 jQuery 新手。任何人都可以建议一种替代方法来隐藏 div.popup 兄弟姐妹点击任何。

谢谢..

Check this code.

<li>one <a href="#" class="opt">delete</a>
        <div class="popup">
            <span class="tip"></span><a href="#" class="btn">deletebutton</a></div>
    </li>

code used to hide/show div.popup

$('.opt').live('click', function(e) {
    e.preventDefault();
    $(".popup").slideUp();
    $(this).closest("li").find(".popup").stop(true, false).slideToggle();
});

In click delete to open each div.popup but second click on the opened div.popup makes the span.tip to disappear. It does not appear anymore without refreshing page.

$(".popup").slideUp();

I found the problem is due to this code. I'm using this code to hide all other opened .popup on click of any delete anchor. I'm new to jQuery. Can anyone suggest an alternative method to hide div.popup siblings on click on any.

Thanks..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼睛会笑 2024-12-25 08:28:02

问题是,在slideToggle期间,jQuery正在将弹出元素更改为“overflow-x:hidden”,因此超出边界的tip元素保持隐藏状态。我对 jsfiddle 进行了更新,使其包含弹出 div 内的提示元素。动画看起来有点不同,但我相信你可以通过一些技巧让它看起来像以前一样。 http://jsfiddle.net/6vKct/5/ (我将提示更改为蓝色背景这样它就更明显)

我将

  • 弹出div顶部从“20px”更改为“15px”,
  • 提示div顶部从“-5px”更改为“0px”
  • 使btn元素相对定位
  • 通过设置顶部将btn元素向下移动到“5px”
  • 将背景颜色样式从整个弹出 div 移至 btn

实际上,我只是使弹出 div 更大,将其向上移动并将尖端移到其中。

The problem is that during slideToggle jQuery is changing the popup element to have "overflow-x: hidden" thus the tip element, which is outside of the bounds stays hidden. I made an update to the jsfiddle so that it includes the tip element inside of the popup div. The animation looks a little different but I'm sure you can get it to look like it used to with a little finessing. http://jsfiddle.net/6vKct/5/ (I changed the tip to have a blue background so that it's more visible)

I changed

  • the popup div top from "20px" to "15px"
  • the tip div top from "-5px" to "0px"
  • made the btn element relative positioned
  • moved the btn element down by setting the top to "5px"
  • moved the background color style from the entire popup div to just the btn

In effect I just made the popup div larger, moved it up and moved the tip inside of it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文