Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Toggle child element onclick of parent element

$(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.
Comment

PREVIOUS NEXT
Code Example
Javascript :: An Array Of Functions With Parameter 
Javascript :: A Method In Class That Accesses A Property 
Javascript :: javascript call function change last default value 
Javascript :: es6 javascript return types 
Javascript :: NG0100: Expression has changed after it was checked 
Javascript :: send a message in the first channel discord.js 
Javascript :: Update A Request() Property 
Javascript :: prisma get single data query 
Javascript :: js beutify node.js 
Javascript :: pnpm tailwind react 
Javascript :: button style when clicked and unclicked react material 
Javascript :: javascript variable scope in if statement 
Javascript :: Prevent HTTP Parameter Polution in NodeJS 
Javascript :: Proper Way To Access Model(s) Data From Collection In Backbone 
Javascript :: Example Vuex Store 
Javascript :: react custum toogle 
Javascript :: angular button click event 
Javascript :: inline css in react js 
Javascript :: jquery textarea value 
Javascript :: javascript promise example 
Javascript :: react how to get checkbox value on click 
Javascript :: nextjs link 
Javascript :: animation js 
Javascript :: how to convert string to random case in javascript 
Javascript :: EACCES: permission denied /delete express.js 
Javascript :: truthy or falsy 
Javascript :: JavaScript WeakMap Methods 
Javascript :: JavaScript Code Blocks 
Javascript :: jQuery Traversing - Ancestors 
Javascript :: javascipt 
ADD CONTENT
Topic
Content
Source link
Name
1+4 =