Hello,
I am creating dynamic span using document.createElement property. But in the html it creates span like this...

<span id='dispSpan' />

What I want is to create the span like this....

<span id='dispSpan'></span>

It doesn't creates start & end tags instead it creates only one tag if I use document.createElement. How can I create such kind of span? Please help me..
Thanks in advance....

    I may be wrong but I dont think you can dynamicly create a tag with createElement. You can set or change the value of a tag:

       function changeText(isText, id){
            newObj = document.createElement('span');
            newValue = document.createTextNode(isText);
            newObj.appendChild(newValue);
            objExisting = document.getElementById(id);
            objExisting.appendChild(newObj);
         }
    
    <input type="button" onclick="javascript:changeText('New Text', 'one')" value="Set Text" />
    
    <span id="one"></span>
    
      Write a Reply...