newTR.id = list[1] + rowID;
if(newTR.rowIndex%2==1){
newTR.className="oddRow";
}else{
newTR.className="evenRow";
}
newTR.onmouseover="alert(this.id);";
newTR.onmouseout="onmouseouttr(this.id);";
newTR.onDblClick="onClicktr(this.id);";创建一行的代码
创建出来后复制到dwr里面代码如下<tr class="oddRow" id="wmwSearchFrame1" onmouseover="alert(this.id);" onmouseout="onmouseouttr(this.id);" onDblClick="onClicktr(this.id);">
<td>1</td>
<td>
<input id="121" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="128" size="20"></td>
<td>
<input id="121" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="129" size="20"></td>
<td>
<input id="121" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="130" size="20"></td>
<td>
<input id="121" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="131" size="20"></td>
<td>
<input id="121" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="121"></td>
</tr>
<tr class="evenRow" id="wmwSearchFrame2" onmouseover="alert(this.id);" onmouseout="onmouseouttr(this.id);" onDblClick="onClicktr(this.id);">
<td>2</td>
<td>
<input id="122" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="132" size="20"></td>
<td>
<input id="122" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="133" size="20"></td>
<td>
<input id="122" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="134" size="20"></td>
<td>
<input id="122" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="135" size="20"></td>
<td>
<input id="122" style="width: 100%; height: 21px; border: 0px none; background:" value="12" name="122"></td>
</tr>页面保存成静态页面事件都可以执行
但为什么创建出来的就是不能执行???
在线等待高手解疑
return function (){
alert(this.id);
};
};
newTR.onmouseout=function (){
return function (){
onmouseouttr(this.id);
};
};
newTR.onDblClick=function (){
return function (){
onClicktr(this.id);
};
};
newTR.onmouseover=function(){
trclassName=this.className;
this.className="eventRow";
ishavetr=0;
}
newTR.onmouseout=function(){
if(ishavetr==0){
this.className=trclassName;
trclassName="";
}
}
newTR.onDblClick=function(){
if(eventTrID!=""){
$(eventTrID).className=eventTrclassName;
}
eventTrID=this.id;
ishavetr=1;
eventTrclassName=trclassName;
this.className="eventsRow";
}onmouseover与onmouseout都执行了
但onDblClick就是不执行,怎么回事呀
onDblClick怎么写???
onDblClick
====>
ondblclick
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>新建网页 1</title>
</head><body>
<style>
.oddRow {background:#fee;color:#000}
.evenRow {background:#eef;color:#000}
.eventRow {background:#000;color:#fff}
.eventsRow {background:#fff;color:#f00}
</style>
<table border="1" width="100%" cellspacing="0" cellpadding="0" id=tab></table><script language="javascript">
<!--
//////////////////////////////////////////////////////
onload=TRadd
function $(id){return document.getElementById(id)}
function TRadd(){for (var i=1;i<11;i++)addTR(i)}
var eventTrID="",eventTrclassName
function addTR(rowID){
var list=['','wmwSearchFrame']
var obj=document.getElementById("tab")
var newTR=obj.insertRow()
var newTD=newTR.insertCell()
newTD.innerHTML=rowID+"<input >"
//////////////////////////////////////////////////////
newTR.id = list[1] + rowID;
if(newTR.rowIndex%2==1){
newTR.className="oddRow";
}else{
newTR.className="evenRow";
}
newTR.onmouseover="alert(this.id);";
newTR.onmouseout="onmouseouttr(this.id);";
newTR.onDblClick="onClicktr(this.id);";
newTR.onmouseover=function(){
trclassName=this.className;
this.className="eventRow";
ishavetr=0;
}
newTR.onmouseout=function(){
if(ishavetr==0){
this.className=trclassName;
trclassName="";
}
}
newTR.ondblclick=function(){//err:onDblClick
if(eventTrID!=""){
$(eventTrID).className=eventTrclassName;
}
eventTrID=this.id;
ishavetr=1;
eventTrclassName=trclassName;
this.className="eventsRow";
}
}//-->
</script>
</body></html>
newTR.ondblclick=function(){//err:onDblClick
if(eventTrID!=""){
$(eventTrID).className=eventTrclassName;
}
eventTrID=this.id;
ishavetr=1;
eventTrclassName=trclassName;
this.className="eventsRow";
}
// newTR.ondblclick =function(){
// if(eventTrID!=""){
// $(eventTrID).className=eventTrclassName;
// }
// eventTrID=this.id;
// ishavetr=1;
// eventTrclassName=trclassName;
// this.className="eventsRow";
// }
奇怪,这两个有什么区别?
注释的和没注释的,难道是缓存的问题?
郁闷
newTR.onmouseout="onmouseouttr(this.id);";
newTR.onDblClick="onClicktr(this.id);";这些属性对应的是FUNCTION,不是字符串,非要写字符串,是不能带有参数和括号newTR.onmouseover=alert
newTR.onmouseout=onmouseouttr
newTR.onDblClick=onClicktrTHIS.id在这里无效
非要用的话
function onClicktr(){
var obj = event.srcElement;
alert(obj.id);
}