JSFiddle - React, Tailwind, and code Playground

by vicky081

HTML

<input type="checkbox" name=""/>
<input type="text" name=""/>

JavaScript

$(':checkbox').change(function() {
    var checkbox = $(this);
    var name= $(this).attr("name");
    if (checkbox.prop('checked')) 
    {   
        $("input [name='"+name+"']").prop('disabled', true);


        $("input [name='"+name+"']").focus();
    } else {
        $("input [name='"+name+"']").prop('disabled', false);
    }
})