var aBtn = $('#block_nav').find('a');
// console.log(aBtn.length);
// aBtn.click(function(){$('html,body').animate({scrollTop:$('.1').offset().top}, 800);});
aBtn.each(function(i){
$(this).click(function(){
$('html,body').animate({scrollTop:$('p[class = i ]').offset().top}, 800);
});
});
As above, I want to correspond i in each() to p with class i, but writing $('p[class = i]') like this is not possible. Please find a solution
will
$('p[class = i ]')
替换为$('.' + i)