Dinesh Subhash Patil Dinesh Subhash Patil - 2 years ago 132
HTML Question

create multiple span inside div using javascript

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;
var demoid = document.getElementById('demo');

var spa = document.createElement('span');
spa.id = text;
var text = text+' , ';
spa.innerHTML = text;


console.log("in addTag");


Answer Source

Try like following using jQuery:

$('button').on('click',function (e) {
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download