I work with CreateElemant in JavaScript this is my code:
function generateInputs()
{
    var i = document.createElement("input");
    for(var j=0;j<4;j++)
    {
        var c = document.createElement("input");
        var r = document.createElement("input");
        r.setAttribute('type',"radio");
        document.getElementById('questions').appendChild(r);
        c.setAttribute('type',"input");
        document.getElementById('questions').appendChild(c);
    }
    i.setAttribute('type',"text");
    document.getElementById('questions').appendChild(i);
}
And I want to write it with jQuery but I didn't find an equivalent for createElement()
Just try with:
function generateInputs()
{
    var i = $('<input type="text"/>');
    for(var j=0;j<4;j++)
    {
        var c = $('<input type="text"/>');
        var r = $('<input type="radio"/>');
        $('#questions').append(c).append(r);
    }
    $('#questions').append(i);
}
                        // $("#id"), $("element") or $(".class") for selecting parent
$("#foo").append("<div>hello world</div>")
var txt1="<p>Text.</p>";               // Create element with HTML  
var txt2=$("<p></p>").text("Text.");   // Create with jQuery
var txt3=document.createElement("p");  // Create with DOM
txt3.innerHTML="Text.";
$("p").append(txt1,txt2,txt3);         // Append the new elements 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With