0
所以我有一些使用切换功能设置的div,我希望第一个切换在页面加载时可见,那么执行此操作的最佳方式是什么?由于Jquery在页面加载时启动切换的最佳方式
$('.paneltop').click(function(){
$(this).next('div').animate(
{'height':"toggle"});
$(this).toggleClass('openpane')
所以我有一些使用切换功能设置的div,我希望第一个切换在页面加载时可见,那么执行此操作的最佳方式是什么?由于Jquery在页面加载时启动切换的最佳方式
$('.paneltop').click(function(){
$(this).next('div').animate(
{'height':"toggle"});
$(this).toggleClass('openpane')
您可以使用jQuery.toggle
与.ready()
一起。 它应该是这样的:
$(document).ready(function(){
$(".paneltop").next("div").toggle();
});
注意:如果你希望它是开放的,你可以使用.show()
而不是.toggle()
。
jQuery.toggle - http://api.jquery.com/toggle/
比较容易回答,如果我们有HTML,并在那里你有这个JS更多的上下文。 – Chad
所有我需要的是在上面的函数中切换的高度在页面加载时打开 –