Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

jquery click on parent but not child

$(document).ready(function(){
    $(".header").click(function(){
        $(this).children(".children").toggle();
    });
   $(".header a").click(function(e) {
        e.stopPropagation();
   });
});
Comment

jquery click on parent but not child

$(".header").click(function(e){
     //Do nothing if .header was not directly clicked
     if(e.target !== e.currentTarget) return;

     $(this).children(".children").toggle();
});
Comment

PREVIOUS NEXT
Code Example
Javascript :: kb to mb javascript 
Javascript :: javascript foreach get key and value 
Javascript :: js change video src 
Javascript :: javascript count occurrences of letter in string 
Javascript :: how to sort by newest document mongoose 
Javascript :: jquery checkbox set checked 
Javascript :: how to find parent table of tr in jquery 
Javascript :: console log all events 
Javascript :: increase font size chartjs 
Javascript :: horizontal divider react native 
Javascript :: next js get current url 
Javascript :: get data in date filter sequelize 
Javascript :: javascript canvas mousemove 
Javascript :: js regex domain name 
Javascript :: carousel speed bootstrap 
Javascript :: onload javascript function call 
Javascript :: javascript generate random string 
Javascript :: momentjs number of days between two dates 
Javascript :: check jquery version in chrome 
Javascript :: each option select jquery 
Javascript :: post antiforgerytoken jquery 
Javascript :: how to clean modal on js in event hide 
Javascript :: text to speech using javascript 
Javascript :: threejs cube mesh 
Javascript :: kendo dropdownlist value jquery 
Javascript :: javascript array of all characters 
Javascript :: nodejs delete folder recursively 
Javascript :: javacript open url in new tab 
Javascript :: javascript print subarray from index to indeex 
Javascript :: how to get domain name in react 
ADD CONTENT
Topic
Content
Source link
Name
9+7 =