dnn 中的 jquery SlideToggle

发布于 2024-10-25 01:31:20 字数 692 浏览 11 评论 0原文

我正在尝试制作一个信息框,当我单击头部时,内容会向下滑动
但当我这样做时,它只是向下滑动然后再次向上。
它位于 ascx 文档中,我需要在 dotnetnuke 容器上使用它
它在 html 文件中完美运行
这是代码

<script type="text/javascript">
    $(document).ready(function () {
        $('.head').click(function () {
            $('.content').slideToggle();
        });
    });
</script>

$(document).ready(function () {
    $('.textbox .content:eq(1)').hide();
    $('.textbox .head').click(function () {
        if ($(this).next('.content').is(':visible')) {
            $(this).next('.content').slideUp();
        } else {
            $(this).next('.content').slideDown();
        }
    });
});

I'm trying to make a infobox when i click the head the content slides down
but when i do it it just slides down and then up again.
It is in a ascx document and i need to use it on a dotnetnuke container
it works perfectly in a html file
here's the code

<script type="text/javascript">
    $(document).ready(function () {
        $('.head').click(function () {
            $('.content').slideToggle();
        });
    });
</script>

or

$(document).ready(function () {
    $('.textbox .content:eq(1)').hide();
    $('.textbox .head').click(function () {
        if ($(this).next('.content').is(':visible')) {
            $(this).next('.content').slideUp();
        } else {
            $(this).next('.content').slideDown();
        }
    });
});

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

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

发布评论

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

评论(1

春风十里 2024-11-01 01:31:20

在第一个示例中,如果页面上有多个相同容器,您将切换所有内容区域。

第二个示例看起来应该可以工作,但是,同样,如果您有容器的多个实例,并且该脚本位于容器本身中,则您将多次注册处理程序。尝试将脚本移动到外部文件并在代码中引用它,这样它只会被包含一次。有关示例,请参阅容器中的 DotNetNuke jquery 脚本

In the first example, you'll toggle all of the content areas if you have multiples of the same container on the page.

The second example looks like it should work, but, again, if you have multiple instances of the container, and that script is in the container itself, you'll register the handler multiple times. Try moving the script to an external file and referencing it in code, so it only gets included once. See DotNetNuke jquery script in container for an example of that.

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