JSFiddle - React, Tailwind, and code Playground

by yeuem1vannam

HTML

<input type="button" id="bt11" value="Button11"/>
<input type="button" id="bt12" value="Button12"/>
<input type="button" id="bt2" style="display:none" value="Button2"/>

JavaScript

var xxx = null;
$("[id^='bt1']").on("click", function(e){
    console.log($(this).attr("id"));
    if (xxx) {
        console.log("in 11");
        $("#bt2").hide();
        xxx = null;
    } else {
        console.log("in 12");
        $("#bt2").show();
        xxx = $(this).attr("id");
    }
})

$("#bt2").on("click", function(e){
    console.log("in 2");
    $("[id='" + xxx + "']").trigger("click");
})