create multiple span inside div using javascript

html, javascript

Solution

Try like following using jQuery:

$('button').on('click',function (e) {
     $('#demo').append('<span>'+$('textbox').val()+'</span>');
 });

Problem

I have one image, when I am clicking on that image, I am getting one textbox and a button. By clicking on button, I want to put that textbox values in separate spans inside a div with id demo. Ho I can do that using javascript only? Here is the function in which I was trying the same(I am trying so lots of error must be there) ``` function addTag(){ var text = document.getElementById('title').value; //console.log(text); var demoid = document.getElementById('demo'); console.log(demoid); var spa = document.createElement('span'); spa.id = text; spa.appendChild(demoid); var text = text+' , '; spa.innerHTML = text; console.log(spa.id); jQuery("#form_panel").hide(); jQuery("#someID").hide(); console.log("in addTag"); } ```

Original source