Thursday, December 6, 2012

style.color

Properti style.color digunakan untuk menetapkan warna teks dari suatu elemen.

Sintaks:

obj.style.color = value;

Nilainya:

Contoh:

<HTML> <HEAD> <TITLE>style.color</TITLE> <STYLE TYPE="text/css"> #myp { border: 1px solid red; } </STYLE> <SCRIPT TYPE="text/javascript"> function changeColor() { var list = document.forms[0].listColors; document.getElementById("myp").style.color = list.options[list.selectedIndex].text; } </SCRIPT> </HEAD> <BODY> <P ID="myp">Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque condimentum ultricies rutrum. Mauris vitae dolor a felis semper bibendum a vitae felis.</P> <FORM> <SELECT NAME="listColors" onChange="changeColor()"> <OPTION SELECTED>transparent <OPTION>aqua <OPTION>blue <OPTION>fuchsia <OPTION>gray <OPTION>maroon <OPTION>silver <OPTION>yellow <OPTION>green </SELECT> </FORM> </BODY> </HTML>