Dynamically Alter color of text

[Total: 0    Average: 0/5]

This example shows (very roughly) how to have text change color in both IE and in NS on some user event.

Head Code:

<script src="http://www.js-examples.com/bin/div_construct.js"></script>
<script>
var msg = new Array();
    msg[0] = '<H1 STYLE="color:black;font-size:12pt">black label</H1>';
    msg[1] = '<H1 STYLE="color:red;font-size:12pt">red label</H1>';
var div1 = new NewDiv(window, "d1", msg[0], 100, 200);
</SCRIPT>


Body Code:

<script type=text/javascript>
div1.output();
var _w=0;
function changeColor() {
_w=_w==0?1:0;
div1.setBody(msg[_w]);
}
</SCRIPT>
<a href="javascript:changeColor()">Change color</a>

Times Viewed: 0

Leave a Reply

Your email address will not be published. Required fields are marked *