»
AnglaisFran�aisVietnamien

Imprimer - Changement de style Tag - JavaScriptBank.com

Version compl�te: jsB@nk » Form » Table » Changement de style Tag
URL: https://www.javascriptbank.com/change-tag-style.html

Changement de style Tag © JavaScriptBank.comOn peut utiliser ce JavaScript pour changer couleur de fond par les visiteurs.

Version compl�te: jsB@nk » Form » Table » Changement de style Tag
URL: https://www.javascriptbank.com/change-tag-style.html



JavaScript
<script language="JavaScript" type="text/JavaScript"><!-- Beginfunction showNewColor() {// setup varsvar 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 elementvar 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 colordocument.getElementById('tagID').style.backgroundColor = newColor;}else {// change style to default colordocument.getElementById('tagID').style.backgroundColor = defaultColor;          }  }else {// This CSS property is not assigned or is not supportedreturn;  }}else {  return;}}// email bug fixes to [email protected]// End ---></script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<p id=tagID>Sampled by JavaScriptBank.com</p><br><br><a href="javascript:showNewColor();">Change Tag Style</a><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->