javascript - 'Uncaught TypeError: vairable.fadeOut is not a function' in for loop -




i'm trying set classname variable , fadeout(). i'm able use fadeout() on query selector directly, not when store in variable.

here's code:

var sections = ["$('.start')", "$('.one')", "$('.two')", "$('.three')", "$('.four')", "$('.five')", "$('.six')","$('.seven')","$('.eight')"]; var begin = $('.begin');  var = 0; var currentsection = sections[i]; var nextsection;  begin.on('click', function(){   for(i=0; < sections.length; i++){     console.log(currentsection);     currentsection.fadeout();     currentsection = sections[i+1];   } }); 

here's video no sound showing what's up: http://screencast-o-matic.com/watch/cbj3rvl8yf

am missing something?

here's link codepen rest of code: https://codepen.io/naturalhanglider/collab/bd90327af7cb6da2620e3a3c4d7f398f/?editors=1010

i dug around, , wasn't able find looking for. please point me in right direction if question has been asked before!

do this. first add unique id html this

<section class="start">   <p><div class="begin button">begin</div></p> </section> <section id="section-1" class="one hidden"> <div class="bg">  <p class="overlay">section one</p> </div> </section> <section id="section-2" class="two hidden">  <p>section two</p> </section> <section id="section-2" class="three hidden">  <p>section three</p> </section> <section id="section-4" class="four hidden">  <p>section four</p> </section> <section id="section-5" class="five hidden">   <p>section five</p> </section> <section id="section-6" class="six hidden">   <p>section six</p> </section> <section id="section-7" class="seven hidden">  <p>section seven</p> </section> <section id="section-8" class="eight hidden">  <p>section eight</p> </section>  

and javascript code in foor loop retrieve them this

var sections = [$('.start'), $('.one'), $('.two'), $('.three'), $('.four'), $('.five'), $('.six'),$('.seven'),$('.eight')]; var begin = $('.begin');  var = 0;  begin.on('click', function(){   for(i=0; < sections.length; i++){     console.log(currentsection);     var currentsection = $("#section-"+i);     currentsection.fadeout();   } }); 

i dont know tryinng fade cause cant see html in codepen error not occur again doing this.

or can this

begin.on('click', function(){    sections.foreach(function(element) {      console.log(element);      element.fadeout();      console.log(element); 

});





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -