"OM" <OM@yahoo.com> writes:
I've found out that I can use <div id = "variable"><div> to change text and
pictures on mouseovers.
All I have to do is change "variable" to be the HTML text I want.
I am not sure what you mean. Do you just write
variable = "html code"
or do you write
variable.innerHTML = "html code"
?
The latter works in some browsers, but not all.
I can even change the text to have images.
Is this method recommended?
No. If you need to refer to the div with id="variable", it is not
recommended to just write "variable" or "document.variable". Some
browsers make that work, others don't, and noone say that they
should.
The recommended method is:
document.getElementById("variable")
To change the contents of the div, you can assign to the innerHTML
property. It is not standard, but is widely available.
Should I be doing it another way?
I prefer the W3C DOM methods to build content. To add an image to the
div, I would write
var myImg = document.createElement("img");
img.src = "PicA.png";
document.getElementById("variable").appendChild(im g);
It is longer than using innerHTML, though.
/L
--
Lasse Reichstein Nielsen -
lr*@hotpop.com
Art D'HTML: <URL:http://www.infimum.dk/HTML/randomArtSplit.html>
'Faith without judgement merely degrades the spirit divine.'