开发者

Jquery best way to initiate toggle on page load

开发者 https://www.devze.com 2023-04-11 18:33 出处:网络
so I am have some divs set up with a toggle function, and I want the first to be toggled visible on page load, what is the be开发者_如何学Cst way to do this? Thanks

so I am have some divs set up with a toggle function, and I want the first to be toggled visible on page load, what is the be开发者_如何学Cst way to do this? Thanks

$('.paneltop').click( function(){
    $(this).next('div').animate(
    {'height':"toggle"});
    $(this).toggleClass('openpane')     


You can use jQuery.toggle along with .ready(). It should look like this:

$(document).ready(function(){
  $(".paneltop").next("div").toggle();
});

Note: if you want it to be open, you can use .show() instead of .toggle().

jQuery.toggle - http://api.jquery.com/toggle/

0

精彩评论

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

关注公众号