php - Change the background image of a div depending on which link is selected in the navigation -


i'd change background image of div depending on wich link selected in navigation!

exemple : let's have menu item called :

#nav li.menu-item-59 

when link selected changes

#nav li.menu-item-59.selected 

i'd whenever 1 of menu item selected background image of div footer change different file...

i've read articles sibling operators can't seem make work , i'm not sure best way go .. can help? ! :d

it looks you're using js add class of selected menu. @ same time you're adding that, add the menu item name footer. like:

var menuname = $(this).attr('id'); $('.footer').addclass(menuname); 

then in css footer, add class end of element:

.footer.menu-item-59 {   // background goes here } 

based on fiddle below, try:

$(window).scroll(function(){      for(var = 0; < sections.length; i++)     if($(window).scrolltop() +5 >= sections[i].top &&     $(window).scrolltop() <= sections[i].bottom){       sections[i].link.addclass('selected')       .siblings().removeclass('selected');       var selection = 'selected' + i; // new stuff starts here       $('footer #flag').removeattr('class');       $('footer #flag').addclass(selection);     } }); 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -