javascript - Nested function and else condition not working -


i practicing js doing project , have run issues (again). upfront, explain want. have top level buttons nation names, on click pic fade container that. gets pic first array on line 1.this works well. however... when container visible, want click handler on "next" button right. handler 1 function (line 29-42) animates second div(.containsnext) changing opacity , rotate values. function calls function (next, should change target div background pics new array) , has if else statement. if condition works supposed to. else condition not run, if take out nested next() function.

i think error (console doesn't return one) on next function lines 15 , 16, know lines "funny":-)

and if statement in wrapper function not work either.

how fix this? please make sure select france, italy or croatia buttons, or next button not respond @ (do not know why either). 1 more question on side, economical way store pics nations arrays selected/triggered next button? how implement proper nations array selected based on top button nation selection?

thank guys

function    var imglenght = 3;    var currentimg = 1;    function next() {       var imgcontainer = document.queryselector(".containsnext");    if(currentimg > 0)        {        imgcontainer.style.background = "url(" + "im[currentimg-1]" + ")";        currentimg = currentimg - 1;        }    }  

link pen:

http://codepen.io/damianocel/pen/gpgglb

use correctly nested quotes:

  imgcontainer.style.background = 'url("' + im[currentimg-1] + '")'; 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -