请问各位JS高手,对于静态表格的单元格怎么取值啊? 没有onmouseclick这个事件的,只有onclick.看看这个行不行:onclick="if(!this.innerHTML)='';" 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <HTML><head><style type="text/css">td{ text-align:center}.tdOver{border:1px solid;border-color: buttonface threeddarkshadow threeddarkshadow buttonface;cursor:hand;}</style><script language="javascript">function tdOver(curTd){ curTd.className="tdOver";}function tdOut(curTd){ curTd.className="td";}function tdClick(curTd){ var tdVal=curTd.innerText; if(tdVal=="N/A") return false; window.location="http://www.163.com";}</script></head><BODY><TABLE border=1 width="450"><TR> <TD>AAA</TD> <TD>BBB</TD> <TD onMouseOver="tdOver(this)" onMouseOut="tdOut(this)" onClick="tdClick(this)">111</TD> <TD onMouseOver="tdOver(this)" onMouseOut="tdOut(this)" onClick="tdClick(this)">222</TD> <TD>CCC</TD></TR></TABLE></BODY></HTML> 你要是已知要的范围:可以当鼠标发生移动时检测当前的对象,是TR时就检测它的TABLEINDEX是不是在111 - 1 --> 222-1内,是话再检测是不是空,否则就什么! <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><HTML><BODY><TABLE border=1 id="table1"><TR> <TD>AAA</TD> <TD>BBB</TD> <TD onclick="clickIt(this)">111</TD> <TD onclick="clickIt(this)">222</TD> <TD>CCC</TD></TR></TABLE></BODY></HTML><script>function window.onload(){ table1.onmouseover = overIt; table1.onmouseout = outIt;}function overIt(){ var the_td = get_Element(event.srcElement,"td"); if(the_td == null) return; var the_tr = the_td.parentElement; if(the_tr.rowIndex == 0){ for(var i = 0 ; i < the_tr.cells.length; i++){ if(i == 2 || i == 3){ with(the_tr.cells[i]){ runtimeStyle.backgroundColor ="#BEC5DE"; style.cursor = "hand"; } } } }} function outIt(){ var the_td = get_Element(event.srcElement,"td"); if(the_td == null) return; var the_tr = the_td.parentElement; if(the_tr.rowIndex == 0){ for(var i = 0 ; i < the_tr.cells.length; i++){ if(i == 2 || i == 3){ with(the_tr.cells[i]){ runtimeStyle.backgroundColor =""; } } } }}function get_Element(the_ele,the_tag){ the_tag = the_tag.toLowerCase(); if(the_ele.tagName.toLowerCase()==the_tag)return the_ele; while(the_ele=the_ele.offsetParent){ if(the_ele.tagName.toLowerCase()==the_tag)return the_ele; } return(null);}function clickIt(curTd){ var tdVal=curTd.innerText; if(tdVal=="N/A") return false; window.location="other.htm";}</script>看看是不是你要的? window.setTimeout问题 【急!!】两个JS文件冲突,求达人帮我看看,该怎么解决。 请高手帮忙看一下,我这段脚本哪里不行 一段JS页面搜索程序,在FireFox下不能执行. 用button控制必填项的javascript怎么写 如何实现打开网页聚焦第一个文本框 ,并按回车聚焦逐个文本框? 源代码与代理服务器求助!!!! 如何在网页中Word等office文件的连接点击后不直接打开,而提示打开、保存、取消等? 如何自动打开输入法 如何判断一个日期时候合法? 控制表格的背景 表格问题,急急急!
<head>
<style type="text/css">
td{ text-align:center}
.tdOver{border:1px solid;border-color: buttonface threeddarkshadow threeddarkshadow buttonface;cursor:hand;
}
</style>
<script language="javascript">
function tdOver(curTd){
curTd.className="tdOver";
}
function tdOut(curTd){
curTd.className="td";
}
function tdClick(curTd){
var tdVal=curTd.innerText;
if(tdVal=="N/A") return false;
window.location="http://www.163.com";
}
</script>
</head>
<BODY>
<TABLE border=1 width="450">
<TR>
<TD>AAA</TD>
<TD>BBB</TD>
<TD onMouseOver="tdOver(this)" onMouseOut="tdOut(this)" onClick="tdClick(this)">111</TD>
<TD onMouseOver="tdOver(this)" onMouseOut="tdOut(this)" onClick="tdClick(this)">222</TD>
<TD>CCC</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<HTML><BODY>
<TABLE border=1 id="table1">
<TR>
<TD>AAA</TD>
<TD>BBB</TD>
<TD onclick="clickIt(this)">111</TD>
<TD onclick="clickIt(this)">222</TD>
<TD>CCC</TD>
</TR>
</TABLE>
</BODY>
</HTML>
<script>
function window.onload(){
table1.onmouseover = overIt;
table1.onmouseout = outIt;
}function overIt(){
var the_td = get_Element(event.srcElement,"td");
if(the_td == null) return;
var the_tr = the_td.parentElement;
if(the_tr.rowIndex == 0){
for(var i = 0 ; i < the_tr.cells.length; i++){
if(i == 2 || i == 3){
with(the_tr.cells[i]){
runtimeStyle.backgroundColor ="#BEC5DE";
style.cursor = "hand";
}
}
}
}
}
function outIt(){
var the_td = get_Element(event.srcElement,"td");
if(the_td == null) return;
var the_tr = the_td.parentElement;
if(the_tr.rowIndex == 0){
for(var i = 0 ; i < the_tr.cells.length; i++){
if(i == 2 || i == 3){
with(the_tr.cells[i]){
runtimeStyle.backgroundColor ="";
}
}
}
}
}function get_Element(the_ele,the_tag){
the_tag = the_tag.toLowerCase();
if(the_ele.tagName.toLowerCase()==the_tag)return the_ele;
while(the_ele=the_ele.offsetParent){
if(the_ele.tagName.toLowerCase()==the_tag)return the_ele;
}
return(null);
}function clickIt(curTd){
var tdVal=curTd.innerText;
if(tdVal=="N/A") return false;
window.location="other.htm";}
</script>
看看是不是你要的?