开发者

jquery SlideToggle in dnn

开发者 https://www.devze.com 2023-02-18 18:34 出处:网络
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.

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开发者_JS百科

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();
        }
    });
});


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消