»
EnglishFrenchVietnamese

Print - Change Tag Style - JavaScriptBank.com

Full version: jsB@nk » Form » Table » Change Tag Style
URL: https://www.javascriptbank.com/change-tag-style.html

Change Tag Style © JavaScriptBank.comCan use this JavaScript to change background color by visitors.

Full version: jsB@nk » Form » Table » Change Tag Style
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 ajslackmeyer@hotmail.com// 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-->