Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how do I add text to an Image dynamically through javascript

Status
Not open for further replies.

healingtao

Programmer
Jul 17, 2003
1
0
0
US
On my html page I have an image on top of the page. This image is just a blue background.I'd like to add some text to the image dynamically based on the parameters to this html page. How can I do this?
If this is not possible, how can I define some string object in the top header section and add text to it dynamically and then color the background for that section blue?
 
Using CSS you can specify an image for whatever element you need ie:
Code:
<div id=&quot;myDiv&quot; style=&quot;background-image: url(bg.jpg);&quot;></div>
Then you can set the text inside the div by referring to it programmatically:
Code:
document.getElementById('myDiv').innerText = 'Some Text';
or:
Code:
document.getElementById('myDiv').innerHTML = '<h1>Some Text</h1>';
 
hi,

can u post the code, so that I can see what you are using...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top