JSFiddle - React, Tailwind, and code Playground

by Matt Hopkins

HTML

<div id="dynamicForm">

</div>

JavaScript

function createInputfield(mainID, childID, labelFor, labelText, spanText){
    $('#'+ mainID).append('<li id=' + childID + '></li>');
    $('#'+ childID).append('<label for=' + labelFor + '>' + labelText + '</label>')
    $('<input>').attr({type: 'text', id: labelFor, name: labelFor}).appendTo('#'+ childID);
    $('#'+ childID).append('<span>' + spanText + '</span>');
}

createInputfield("dynamicForm", "psport", "sport", "Source port", "Enter the source port here (0-65535)");