因此,在我的页面上有一个切换块,现在我需要在同一页面上添加另一个切换块,但是默认情况下,第一个切换块处于活动/打开状态。我一直在研究JS,但到目前为止还没有运气,因此,我需要您的宝贵帮助才能使它正常工作。谢谢!
Java脚本
jQuery(window).load(function(){
$('.toggle-view li').click(function () {
var text = $(this).children('div.toggle-content');
if (text.is(':hidden')) {
text.slideDown('200');
$(this).children('span').html('<i class="icon-minus"></i>');
} else {
text.slideUp('200');
$(this).children('span').html('<i class="icon-plus"></i>');
}
$(this).toggleClass('activetoggle');
});
});
您可以使用类似的方法来做到这一点:
$('.added_class_on_second li').eq(0).children('.toggle-content').show();
只需在第二个类中添加另一个不同的类,或将其定位为:
$('.toggle-view').eq(1).children('li').eq(0).children('.toggle-content').show();
如果您根本不想更改html。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句