Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Toggle image onclicking parent

$(function(){ 
    $(".dropdown-toggle").click(function(){ 
   $(".arrow").attr('src',  
                ($("img").attr('src') == 'images/icon-arrow-down.svg'  
                    ? 'images/icon-arrow-up.svg'  
                    : 'images/icon-arrow-down.svg' 
                     ) 
                )  
    }); 
}); 
//Here .dropdown-toggle is parent class and .arrow is child class
//This toggles image src on click
//This works if there is one child with .arrow class as im multiple .arrow classes if affects all.
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #Toggle #image #onclicking #parent
ADD COMMENT
Topic
Name
2+4 =