JSFiddle - React, Tailwind, and code Playground

by Sohnee

HTML

<div id="dynamicRadioButtons">



</div>

JavaScript

function OnClick(id, labelText) {

    // create a new radio button using supplied parameters
    var newRadio = $('<input />').attr({
        type: "radio", id: id, name: id
    });

    // create a new radio button using supplied parameters
    var newLabel = $('<label />').append(newRadio).append(labelText);
   
    // append the new radio button and label
    $('#dynamicRadioButtons').append(newLabel).append('<br/>');
}

OnClick('test', 'Some Label');