5

I have a span tag inside with there is some html code to create some corners and other things. Now using javascript i want to add some captions to it.The constraint is the original content of span should not get overwritten.

Eg

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

Now i want to add caption in span so that span should look like

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

How can i do it?

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

is this correct?

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
Sanket
  • 149
  • 1
  • 8

1 Answers1

4

You will need to give the span an ID if you going to do it that way. Also the innerHtml should be innerHTML

eg.

<span id="mySpan">  <!-come more complecated html code </span>

document.getElementById('mySpan').innerHTML = "NEWCAPTION" + document.getElementById('mySpan').innerHTML
Cubed Eye
  • 5,581
  • 4
  • 48
  • 64