Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Bảng » Ô đổi màu khi rê chuột
URL: https://www.javascriptbank.com/cell-background-changer.html
Hiệu ứng làm cho một ô sẽ đổi màu nền khi bạn rê chuột đến.
Phiên bản đầy đủ: jsB@nk » Biểu mẫu » Bảng » Ô đổi màu khi rê chuột
URL: https://www.javascriptbank.com/cell-background-changer.html
<STYLE>TD {POSITION: relative}</STYLE><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<SCRIPT language=JavaScript>// This is a cross-browser (IE5.5 & NN4.7) cell background changervar oncell = "c0"function chgColor(celno){ var chgcell if (document.layers) { //browser is NNfor (var i = 1; i < 5; i++){chgcell = "window.document.c" + i + ".bgColor='white'";eval(chgcell);}chgcell = "window.document."+ celno + ".bgColor='orange'";}else // assume IE5{for (var index =1; index < 5; index++) { clrIt = "document.getElementById('c"+ index +"').bgColor='white'"; eval(clrIt);}chgcell = "document.getElementById('"+ celno + "').bgColor='orange'";} eval(chgcell);}function overm(celno){ var chgcell if (document.layers) { // browser is NNchgcell = "window.document."+ celno + ".bgColor='yellow'";}else //assume IE{chgcell = "document.getElementById('"+ celno + "').bgColor='yellow'";} eval(chgcell);}function outm(celno){ var chgcell if (document.layers) { // browser is NNchgcell = "window.document."+ celno + ".bgColor='white'";}else //assume IE{chgcell = "document.getElementById('"+ celno + "').bgColor='white'";} eval(chgcell);}</SCRIPT><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->
<TABLE border=1> <TBODY> <TR> <TD id=c1><A href="http://JavaScriptBank.com" onclick="oncell = 'c1'; chgColor('c1');" onmouseout="if (oncell != 'c1') {outm('c1');}" onmouseover="if (oncell != 'c1') {overm('c1');}">cell 1</A></TD> <TD id=c2><A href="http://JavaScriptBank.com" onclick="oncell = 'c2'; chgColor('c2');" onmouseout="if (oncell !='c2') {outm('c2');}" onmouseover="if (oncell !='c2') {overm('c2');}">cell 2</A></TD> <TD id=c3><A href="http://JavaScriptBank.com" onclick="oncell = 'c3'; chgColor('c3');" onmouseout="if (oncell !='c3') {outm('c3');}" onmouseover="if (oncell !='c3') {overm('c3');}">cell 3</A></TD> <TD id=c4><A href="http://JavaScriptBank.com" onclick="oncell = 'c4'; chgColor('c4');" onmouseout="if (oncell !='c4') {outm('c4');}" onmouseover="if (oncell !='c4') {overm('c4');}">cell 4</A></TD></TR></TBODY></TABLE><!-- This script downloaded from www.JavaScriptBank.com Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->