var td = document.createElement("td");
td.onclick = function(){...};
td.onclick = function(){...};
解决方案 »
- 其实我就一个地方一直没想不通
- 求全能的html加载完毕判断
- JavaScript string 解析度、分、秒
- Microsoft JScript 运行时错误 错误 '800a1391'
- 如何把实例置空
- 如果用javascript来禁止输入中文的大空格?
- 超难的下拉菜单树图显示!各路高手都来看看吧,谢谢!
- 在from中怎么访问iframe中的控件?
- <script language='javascript'>window.location.href = './aaa/index.htm'</script>为什么在2000系统下不执行
- net_lover(孟子E章)请进~!
- 后台如何在不同位置上动态加载图片
- 会Ext的进来瞅瞅,关于AsyncTreeNode加载数据到Tree.没有显示子节点的问题
var td = document.createElement("td");
td.onclick=函数名
在js中定义并实现该函数就可以了。
_tr.onmouseout=OU1(this);
_tr.onmouseover=OV(this);为何不行?
_tr.onmouseover=OV(this); 不需要傳遞this,因為在執行_tr的mouseout和mouseover時,OU1,OV的[[scope]]已經是_tr了。
document.getElementById("div0").innerHTML=tdd;
这么写绝对没有问题。
td.onclick = function(){...};
{
var container=document.getElementById(sParendNode);
var _table=document.createElement("table");
var i,j;
var _TableTextArray=sTableText.split("|",nRows*nCols);
nRows=Math.ceil(_TableTextArray.length/nCols);
container.innerHTML="";
_table.setAttribute("id",sNewTableID);
_table.setAttribute("className","TableStyle01");
//_table.setAttribute("className","mytable");
//表格标题
if (sTableTitle!=undefined)
{
var _TableTitle=_table.createCaption()
_TableTitle.setAttribute("className","TableTitleStyle01");
_TableTitle.innerHTML=sTableTitle;
}
//Thead
// if (sTableHead!=undefined)
// {
// var _TableHead=_table.createTHead()
// _TableHead.setAttribute("className","TableTitleStyle01");
// _TableHead.innerHTML=sTableHead;
// }
//表格第一行
for(i=0;i<1;i++)
{
var _tr=_table.insertRow(i);
_tr.setAttribute("id",sNewTableID+"_row_"+i);
for(j=0;j<nCols;j++)
{
var _td=_tr.insertCell(j);
_td.setAttribute("className","TdTitleStyle01");
var _tdText=(_TableTextArray[i*nCols+j]==undefined?" ":_TableTextArray[i*nCols+j]);
_td.innerHTML=_tdText;
}
}
//数据栏
for(i=1;i<nRows;i++)
{
var _tr=_table.insertRow(i);
_tr.setAttribute("id",sNewTableID+"_row_"+i);
if (i%2==0)
{
_tr.setAttribute("className","TdColorStyle01");
_tr.onMouseOut=OU1(_tr);
}
else
{
_tr.setAttribute("className","TdStyle01");
_tr.onMouseOut=OU2(_tr);
}
//_tr.onMouseOver=OV(_tr);
for(j=0;j<nCols;j++)
{
var _td=_tr.insertCell(j);
var _tdText=(_TableTextArray[i*nCols+j]==undefined?" ":_TableTextArray[i*nCols+j]);
_td.innerHTML=_tdText;
}
}
//TFoot
// if (sTableFoot!=undefined)
// { var _TableFoot=_table.createTFoot()
//_TableFoot.setAttribute("className","TableTitleStyle01");
// _TableFoot.innerHTML=sTableFoot;
// }
container.appendChild(_table);
}为何生成的表格行全是_tr.onMouseOut=OU1(_tr); OU1设置的颜色,并且onMouseOut和onMouseOver 不起效果
<head>
</head>
<body>
<table width="100%" border="1">
<tr id="colortr">
<td> </td>
<td> </td>
</tr>
</table>
</body>
<script type="text/javascript">
var t=document.getElementById("colortr");
t.onMouseOut=OU(t);
t.onMouseOver=OV(t);
function OV(o)
{ //mouseover
o.style.backgroundColor='#FFFFCC';
o.style.color='#0022FF';
o.style.cursor='hand';}
function OU(o)
{ //mouseout
o.style.backgroundColor='#FFFFFF';
o.style.color='#000000';
}
</script>
</html>//为何mouseover mouseout 不起作用
<head>
</head>
<body>
<table width="100%" border="1">
<tr id="colortr">
<td> </td>
<td> </td>
</tr>
</table>
</body>
<script type="text/javascript">
var t=document.getElementById("colortr");
t.onmouseout=function(){OU(t)};
t.onmouseover=function(){OV(t)};
//document.getElementById("colortr") = t;
function OV(o)
{ //mouseover
o.style.backgroundColor='#FFFFCC';
o.style.color='#0022FF';
o.style.cursor='hand'; }
function OU(o)
{ //mouseout
o.style.backgroundColor='#FFFFFF';
o.style.color='#000000';
}
</script>
</html>