html - Show Hidden Submenu onclick - JQuery -


i great code jrulle:

http://jsfiddle.net/jrulle/23kfnbx7/3/

can explain me how use complete parent-link instead of image open sub menu? , 1 sub menu shown same time?

i tried realize that, got - sub menu shown clicking link

but arrows not change.

    $('li.parent').on("click",function(){        $(this).children('a').siblings('ul.children').slidetoggle();     }); 

sorry misspelling something, big thank's , greetings germany.

you need bind click event links well. so, please change

$('li.parent').on("click",

to

$('.parent img, .parent a').on("click",

here demo: https://jsfiddle.net/23kfnbx7/8/

    $('.parent img, .parent a').on("click", function () {         var img = $(this);         if ($(this).next('img').length) {             var img = $(this).next('img');         }         if (img.hasclass('open')) {             img.removeclass('open');                         img.attr('src', 'http://upload.wikimedia.org/wikipedia/commons/f/f7/arrow-down-navmenu.png');                     } else {             img.addclass('open');             img.attr('src', 'http://upload.wikimedia.org/wikipedia/commons/0/01/arrow-up-navmenu.png');         }        img.siblings('ul.children').toggle();     }); 

Comments

Popular posts from this blog

java - Custom OutputStreamAppender not run: LOGBACK: No context given for <MYAPPENDER> -

java - UML - How would you draw a try catch in a sequence diagram? -

c++ - No viable overloaded operator for references a map -