JSFiddle - React, Tailwind, and code Playground

by Norlihazmey Ghazali

HTML

<div id="a">Click me
    <p></p>
    <div></div>
    <div></div>    
</div>

JavaScript

$('#a').on('click', function(){
    var div = $(this).children('div').length;
    var p = $(this).children('p').length;
    
    if(div >= 2)
    {
        alert('div exists : ' + div);
        //do your stuff here
    }
    else
    {
        alert('i have div below than two');
        //do your stuff here if below than two
    }
    
    //same goes with p
});