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

document.getElementById( 'child1' ).onclick = function( e ) {
    console.log( 'child1' );
    e.preventDefault();
};

document.getElementById( 'parent1' ).onclick = function( e ) {
    console.log( 'parent1' );
};

document.getElementById( 'child2' ).onclick = function( e ) {
    console.log( 'child2' );
    return false;
};

document.getElementById( 'parent2' ).onclick = function( e ) {
    console.log( 'parent2' );
};

document.getElementById( 'child3' ).onclick = function( e ) {
    console.log( 'child3' );
    e.stopPropagation();
};

document.getElementById( 'parent3' ).onclick = function( e ) {
    console.log( 'parent3' );
};