开发者

Close jQuery hide/show div on load?

开发者 https://www.devze.com 2023-02-19 14:52 出处:网络
I have a jQuery hide/show div script for the FAQ portion of my page. Everything works great except the questions are opened upon loading and I would like them to be closed.

I have a jQuery hide/show div script for the FAQ portion of my page.

Everything works great except the questions are opened upon loading and I would like them to be closed.

Here is the script:

<script type="text/javascript">  
$(document).ready(function(){

$('.faq-row-head a').click(function() {
        $(this).parent().toggleClass('opened');
        $(this).parents('.faq-row').find('.faq-row-entry').slideToggle();
        return false开发者_开发知识库;
    });

    $('.faq-close').click(function() {
        $(this).parents('.faq-row').find('.opened').removeClass('opened');
        $(this).parents('.faq-row').find('.faq-row-entry').slideUp();
        return false;
    });
});

</script>

Here

Could anyone please help me out?


Put this in the first line:

$(".faq-div").hide();


Have the row entries hidden by default. Adding a style="display: none" attribute will do what you want.


first use the below line while loading ..

$(this).parents('.faq-row').find('.faq-row-entry').hide();

try it once ..i'm not sure .


Move all the scripts to end of your html/jsp and then try to add this in first line of $(document).ready function :

$(".faq-row-entry").hide();
0

精彩评论

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