jquery - 如何隐藏已经被jquery隐藏的div的背景图片

标签 jquery css

这个解释起来有点困惑。在我的页面上http://newmedia.leeds.ac.uk/ug10/cs10mm/abduction.html 我有一个显示“更多”和“更少”的选项。单击时,会出现一个带有文本和背景图像的下拉列表。然而,下拉 div 的背景图像的一小部分(顶部)不会隐藏。有谁知道这是为什么?

下面是 html,然后是 css:

<div id="MORE">

    <button id="more">More</button>
    <button id="less">Less</button>

<div id="instructions">
    <p style="display: none"> The Mayor of Scaredy Cat Town has been abducted. Lawlessness has broken out across London and the city needs your help    to find him. Follow the links on this site to scour the city in search of The Mayor. A reward, courtesy of The Mayor and his staff, is  available for anyone able to find him. <br /> The Reward... <br /> An exclusive night of entertainment at the Mayors up-market bar, hosted by his   head waiter,Henri. </p>
</div>

    <script>
        $("button#more").click(function () {
        $("p").show("slow");
        });

      $("button#less").click(function () {
      $("p").hide("slow");
    });    
    </script>
</div> 

CSS...

#MORE {
    position:relative;
    z-index:100;
}

#more, #less {
    background:none;
    border:none;
    color:#FFF;
    font-family:Verdana, Geneva, sans-serif;
    cursor: pointer;

最佳答案

发生这种情况是因为您隐藏了 p 标签并且背景位于其容器 instructions 上。 而是隐藏它。

$("#instructions").show("slow");

关于jquery - 如何隐藏已经被jquery隐藏的div的背景图片,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8763176/

相关文章:

javascript - 检查设备是否为 iPad,然后停止运行 jQuery 函数

javascript - 是否可以在元素内执行 mousedown 功能,但不能在子元素内执行?

html - 如何在悬停时使按钮内的文本透明?背景应该保持不变

javascript - 如何随机化背景颜色和 svg

javascript - 如何修复 "TypeError: Cannot read properties of undefined (reading ' useSystemColorMode')"

html - 具有动态高度的 Flex-wrap

html - Firefox 100% 宽度过度扩展父 Div

javascript - 如何处理捆绑在一起时仅在某些页面上运行的 JavaScript

jquery - shell 脚本和 jQuery

jquery - 如何使用 jQuery 获得脉动效果?