开发者

adding data to span tag dynamically

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 htm开发者_运维问答l code </span>

How can i do it?

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

is this correct?


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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜