Adding data to dynamically display a tag

I have a span tag inside, there is some html code to create some angles and other things. Now, using javascript, I want to add some captions to it. A constraint is the original contents of a range that should not be overwritten.

For instance,

<span> <!-some more complicated html code </span> 

Now I want to add a title to the span so that the span looks like

 <span> NEW CAPTION <!-some more complicated html code </span> 

How can i do this?

 document.getElementById.innerHtml = "NEWCAPTION" + document.getElementById.innerHtml 

Is it correct?

+4
source share
1 answer

You will need to specify an ID interval if you are going to do this. Also innerHtml should be innerHTML

eg.

 <span id="mySpan"> <!-come more complecated html code </span> document.getElementById('mySpan').innerHTML = "NEWCAPTION" + document.getElementById('mySpan').innerHTML 
+3
source

All Articles