About jq traversing each() - Stack Overflow
PHP中文网
PHP中文网 2017-05-19 10:12:02
0
1
472
       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

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(1)
世界只因有你

will$('p[class = i ]') 替换为$('.' + i)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template