<script language="JavaScript" type="text/JavaScript"> <!-- Begin function showNewColor() { // setup vars var defaultColor = "white"; var newColor = "#ff9999"; // other supported styles // myElement.style.fontSize = "24px"; // myElement.style.fontFamily = "Verdana, Arial, Courier New"; // myElement.style.textDecoration = "underline"; // myElement.style.fontWeight = "normal"; // myElement.style.visibility=="hidden"; if((document.getElementById)&& (document.getElementById('tagID')!=null)) { // Get a reference to the element var myElement = document.getElementById('tagID'); // Check the element's style object and background property are available if ((myElement.style)&& (myElement.style.backgroundColor!=null)) { // Check the value of the property if(myElement.style.backgroundColor == 'white'){ // change style to new color document.getElementById('tagID').style.backgroundColor = newColor; }else { // change style to default color document.getElementById('tagID').style.backgroundColor = defaultColor; } }else { // This CSS property is not assigned or is not supported return; } }else { return; } } // End ---> </script> <table id="tagID" style="background-color:white;" width="200" height="50" cellspacing="2" cellpadding="2"> <tr><td> Aqui será a tag a ser mudada!!! <br><br><a href="javascript:showNewColor();">Mudar o estilo da TAG</a> </td> </td></tr> </table>
Rating: 2.4/5 (454 votos)