JSFiddle - React, Tailwind, and code Playground

by Ralt

HTML

<div id="parent1">
    <div id="child1"><a href="#" id="a1">child1</a></div>
</div>

<div id="parent2">
    <div id="child2"><a href="#" id="a2">child2</a></div>
</div>

<div id="parent3">
    <div id="child3"><a href="#" id="a3">child3</a></div>
</div>

JavaScript

$( '#child1' ).click( function( e ) {
    console.log( 'child1' );
    e.preventDefault();
});

$( '#parent1' ).click( function( e ) {
    console.log( 'parent1' );
});

$( '#child2' ).click( function( e ) {
    console.log( 'child2' );
    return false;
});

$( '#parent2' ).click( function( e ) {
    console.log( 'parent2' );
});

$( '#child3' ).click( function( e ) {
    console.log( 'child3' );
    e.stopPropagation();
});

$( '#parent3' ).click( function( e ) {
    console.log( 'parent3' );
});