IE可以用setAttribute 的,你查看一下网页的源程序,看看cell是否添加了("onmouseover的属性!
解决方案 »
- 崩溃中,拜求AJAX载入内容中如何加入和运行JS效果
- (100分)调用分享代码底部出现空白,怎么去掉?
- javacript 计算订单,,,,,,高手请进,马上给分!!!!100分~~~~~~~~
- javascript 文本框动态的显示加入的数据
- 谁那里有 类似3级菜单http://www.fortinet.com/demo/ 但是是4级菜单
- 超链接 鼠标移入 出现div 鼠标移除 div消失
- 请教一个关于用checkbox页面取值的问题~!
- 字符串连接的问题,急!在线等待!
- 如何将IE窗口标题栏上的"-Microsoft Internet Explorer"去掉?
- 表单验证内嵌出错信息 怎么不对啊
- 上传后,页面传值问题,谢谢
- 为什么样式里面改不了高度
<head>
<script language="javascript">
function addtablerow(address,price,comments)
{
var rowIndex = document.getElementById("resultsbody").rows.length;
var row = document.getElementById("resultsbody").insertRow(rowIndex);
// var row=document.createElement("tr"); //建立一行
var cell=createRlement(address); //创建一个单元格节点
row.appendChild(cell);//把单元格节点增加到建立的行中
cell=createRlement(price);
row.appendChild(cell);
cell=createRlement(comments);
row.appendChild(cell);
//document.getElementById("resultsbody").appendChild(row); //把行增加到id为resultsbody
}
function createRlement(text)
{
var cell =document.createElement("td") //常见一个节点
// var tableNode=document.createTextNode(text); //创建一个文本节点
cell.innerText = text;
cell.setAttribute("onmouseover","alert('22')");
alert(cell.outerHTML); //调试看看属性是否已经加进去了!
return cell;//返回cell setAttribute
}
function getdetail(text)
{
alert(text);
} </script></head>
<body>
<table id="resultsbody" width="500px"><tr><td>22</td><td >33</td><td >44</td></tr></table>
<input type="button" value="test" onclick="addtablerow('上海','100','很好')" /></body>
</html>
alert(cell.outerHTML); //调试看看属性是否已经加进去了!
setAttribute的第二个参数应该用引号引起来!
应该是
"<td onmouseover="getdetail("sss")"">sss</td>"
这样才对的啊
我改了一下
cell.setAttribute("onmouseover","getdetail("text")"); 这样写不对
cell.setAttribute("onmouseover","getdetail(text)");这样写的话得到的是
"<td onmouseover="getdetail(text)"">sss</td>"
怎么回事呢?
怎么回事呢?
<table id="resultsbody" width="500px">
<tr>
<td>22</td>
<td>33</td>
<td>44</td>
</tr>
</table>
<input type="button" value="test" onclick="addtablerow('上海','100','很好')" />
等待高手解释……
function addtablerow(address,price,comments)
{
var row=document.getElementById("resultsbody").insertRow(); //建立一行
var cell=row.insertCell(); //创建一个单元格节点
cell.innerText = address;
cell.setAttribute("onmouseover",function(){getdetail(address)});
// 或cell.onmouseover = function(){getdetail(address)};
var cell=row.insertCell(); //创建一个单元格节点
cell.innerText = price;
cell.setAttribute("onmouseover",function(){getdetail(price)});
var cell=row.insertCell(); //创建一个单元格节点
cell.innerText = comments;
cell.setAttribute("onmouseover",function(){getdetail(comments)});
}
function getdetail(text)
{
alert(text);
}
function getdetail(text)
{
return function (){
alert(text);
}
}