JSFiddle - React, Tailwind, and code Playground

by tiagocarvalho

HTML

<div id="divWithButtonInside">
<input type='button' onclick='javascript:functionToRemove();' value='Button with click event' />
</div>
<input type='button' onclick='javascript:removeOnClick("divWithButtonInside");' value='click to remove event' />

JavaScript

function removeOnClick(divContainerName) 
{
    try
    {
        var cat = document.getElementById(divContainerName);    
        var sub = cat.getElementsByTagName("input");
        var btnElement;
        
        for (var i=0;i<sub.length;i++)
        {
            if (sub[i].getAttribute('type') == 'button')
            {    
                btnElement = sub[i]; 
            }
        }
        btnElement.onclick=''; 
    }
    catch(e){;}
}

function functionToRemove()
{
    alert("Button event to remove");
}