我创建了一个迭代UL / LI的函数。这很好用,我的问题是将值返回到另一个变量。对此最好的方法是什么?谢谢!
Collapsible.accordionMobile= function(){
var distance;
$(window).scroll(function(event) {
var colapsible = $('.collapsible-action').hasClass('collapsible-opened');
if(colapsible) {
$(".tabs").each(function(){
$(".tab1").click(function(){
var clickedEvenAccordion = $(this).offset().top;
//console.log('clickedEvenAccordion: ' + clickedEvenAccordion );
var scrollTop = $(window).scrollTop(),
elementOffset = clickedEvenAccordion;
distance = (elementOffset - scrollTop);
console.log('distanceswq' + distance);
var windowScrolledTopValue = $(window).scrollTop();
console.log('windowScrolledTopValue' + windowScrolledTopValue);
});
return false;
});
}
});
return distance;
}