<script type="text/javascript">
function mouse1()
{
document.getElementById("table1").bgColor = "#FFFF80";
}
function mouse2()
{
document.getElementById("table1").bgColor = "#999999";
}
</script>
<body>
<table id="table1" onmouseout="mouse2();" onmousemove="mouse1();" bgcolor="#999999">
</table>
<table id="table2" onmouseout="mouse2();" onmousemove="mouse1();" bgcolor="#999999">
</table>
</body>
======================
function mouse1(),
function mouse2()
如何实现写一次就可以多次调用呢? 求大神帮忙...感激不尽!
ããæä½æ¥éª¤ï¼
ãã1ãæå¼Dreamweaver软件ï¼ç¶åå¨å建æ°é¡¹ç®ä¸éæ©HTMLï¼
ãã2ãç¹å»âæ件âé项ï¼ç¶åç¹å»âå¦å为âï¼å°æ件å½å为testï¼å¹¶å°å ¶ä¿åå¨çµèæ¡é¢ä¸ï¼
ãã3ãç¼åä¸ä¸ªåºæ¬çhtmlæ件ï¼è¯¥htmlæ件å å«ä¸ä¸ªç¨æ·ååä¸ä¸ªå¯ç è¾å ¥ææ¬æ¡åä¸ä¸ªç¡®å®ä»¥åä¸ä¸ªåæ¶æé®ï¼
ãã4ãå¨titleæ ç¾ä¸æå ¥<script language="JavaScript">js代ç </script>ï¼ç¶åå¨htmlä¸è°ç¨jså½æ°ï¼
ãã5ãå®æjs代ç ç¼ååhtmlè°ç¨js代ç åä¿åtset.htmlæ件ï¼ç¶åå¨æµè§å¨ä¸æå¼test.htmlæ件ï¼æ£æ¥js代ç æ§è¡çææï¼
ãã6ãå¨Dreamweaver软件ä¸æ°å»ºä¸ä¸ªcheck.jsæ件ï¼æ¹æ³åhtmlæ件æ°å»ºï¼ï¼å¨checkæ件ä¸è¾å ¥æ ¡éªå½æ°ï¼
ãã7ãç¶åå¨test.htmlçtitleæ ç¾ä¸å¼ç¨check.jsæ件ï¼
ãã8ãå¨ç¨åºä¸å¼ç¨check.jsæ件ä¸çjså½æ°ï¼ç¶åå¨æµè§å¨ä¸å·æ°test.hmtlæ件ï¼ç¶åå¨usernameçè¾å ¥æ¡ä¸è¾å ¥éæ³å符æ¥æ£éªjs代ç ã
zhou2003737 写的就挺好的。
我给你来个简单的,改动不大的。
<script type="text/javascript">
function mouse(v , flag)
{
if(flag==1)
v.bgColor = "#FFFF80";
else
v.bgColor = "#999999";
}
</script>
<body>
<table id="table1" onmouseout="mouse(this,1);" onmousemove="mouse(this,2);" bgcolor="#999999">
<tr><td>1</td></tr>
</table>
<table id="table2" onmouseout="mouse(this,1);" onmousemove="mouse(this,2);" bgcolor="#999999">
<tr><td>2</td></tr>
</table>
</body>本回答被提问者和网友采纳
function mouse1(var id)
{
document.getElementById(id).bgColor = "#FFFF80";
}
function mouse2(var id)
{
document.getElementById(id).bgColor = "#999999";
}
</script>
<body>
<table id="table1" onmouseout="mouse2("table1");" onmousemove="mouse1("table1");" bgcolor="#999999">
</table>
<table id="table2" onmouseout="mouse2("table2");" onmousemove="mouse1("table2");" bgcolor="#999999">
</table>
</body>
我懂你,你传一个标签的id进来就可以实现多次调用了。我帮你优化了一下。
你只要在鼠标经过的时候吧对象传入函数就好了
js:
<script language="javascript">
function mouse1(obj)
{
//document.getElementById("table1").bgColor = "FFFF80"
document.getElementById(obj).style.fontSize = "22px";
}
function mouse2(obj)
{
document.getElementById(""+obj+"").style.backgroundColor = "#ffffff";
}
</script>
html:
<table id="table1" onmouseout="mouse2('table1');" width="500" height="50" onmousemove="mouse1('table1');" bgcolor="#999999">
<tr><td>2222</td></tr>
</table>
<br />
<table id="table2" onmouseout="mouse2('table2');" height="50" width="500" onmousemove="mouse1('table2');" bgcolor="#999999">
<tr><td>1111</td></tr>
</table>
注意引号。。。
如下:
<script type="text/javascript">
function mouse1()
{
document.getElementByClassName("table1").bgColor = "#FFFF80";
}
function mouse2()
{
document.getElementByClassName("table1").bgColor = "#999999";
}
</script>
<body>
<table class="table1" onmouseout="mouse2();" onmousemove="mouse1();" bgcolor="#999999">
</table>
<table class="table2" onmouseout="mouse2();" onmousemove="mouse1();" bgcolor="#999999">
</table>
</body>
======================
function mouse1(),
function mouse2()
代码没查看效果 你自己写的 自己试试吧