jeudi 28 avril 2016

how to dynamically add input elements one below the other in javascript

I have following code. The input textboxes are getting generated. Only the thing is i wanted them to be added one below the other. Here is my code:

$('.pl').on('click',function(){

        var hiddenInput = document.createElement("input");
        var hiddenButton = document.createElement("button");
        var hiddenTextNode = document.createTextNode("Delete");

        $(this).after(hiddenInput);
        hiddenButton.appendChild(hiddenTextNode);
        $(this).after(hiddenButton);
        $(this).write("<p>hi</p>");
        c=c+1; 
        document.getElementById("h").value = c;

        hiddenInput.name = 'text'+c;
        hiddenInput.class = 'form-control add-polls-container';
        hiddenInput.placeholder = 'Enter Poll Option';

    });



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1NZ2Wnm
via IFTTT

Aucun commentaire:

Enregistrer un commentaire