<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function MouseOver(obj)
{
obj.style.color = "red"
obj.style.cursor = "hand"
}function MouseOut(obj)
{
obj.style.color = "black"
obj.style.cursor = ""
}
//-->
</script>
</head><body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAA</td>
</tr>
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAAAAAAAAAAAAAA</td>
</tr>
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAAAAAAAAAAAAAAAAAAAA</td>
</tr>
</table>
</body>
</html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function MouseOver(obj)
{
obj.style.color = "red"
obj.style.cursor = "hand"
}function MouseOut(obj)
{
obj.style.color = "black"
obj.style.cursor = ""
}
//-->
</script>
</head><body>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAA</td>
</tr>
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAAAAAAAAAAAAAA</td>
</tr>
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAAAAAAAAAAAAAAAAAAAA</td>
</tr>
</table>
</body>
</html>
解决方案 »
- IE中使用jquery load的问题
- 求救:JS中怎么执行命令行无法把结果输出到文件中
- FF下 document.documentElement.scrollTop只表示body对象的,而其他的比如div,span之类
- 请教:如何最小化窗口
- 关于排序,对两个数字连接成的一个字符串 排序,要求按两个数值来排,结果老是按数字的序来排的,有代码贴出
- 请教location.href的用法,100分
- 跪求,马上解决马上给分.谢谢。
- 在JS中,使用列表框为动态数组赋值的问题
- 用get方法的时候有中文问题啊
- 请问"var p=tdObj.previousSibling;"中previousSibling是何含义?(javascript中)
- 一个关于Table的问题
- 哪有HTML和JSCRIPT的詳細學習資料下載﹖
<html>
<head>
<title>动态添加表格内容</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function InsertRow(strID)
{
var obj, objRows, objCells
var lngTDs
var i obj = document.getElementById(strID)
lngTDs = obj.rows(0).cells.length objRows = obj.insertRow()
for (i=0; i<lngTDs; i++) {
objCells = objRows.insertCell()
objCells.innerHTML = "test"
}
}function InsertCell(strID)
{
var obj, objCells
var lngTRs
var i obj = document.getElementById(strID)
lngTRs = obj.rows.length for (i=0; i<lngTRs; i++) {
objCells = obj.rows(i).insertCell()
objCells.innerHTML = "test"
}
}function MouseOver(obj)
{
obj.style.color = "red"
obj.style.cursor = "hand"
}function MouseOut(obj)
{
obj.style.color = "black"
obj.style.cursor = ""
}
//-->
</script>
</head><body>
<a href="javascript: InsertRow('tblEx')">INSERT TR</a> <a href="javascript: InsertCell('tblEx')">INSERT TD</a><br>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="tblEx">
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAA</td>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)"> </td>
</tr>
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAAAAAAAAAAAAAA</td>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)"> </td>
</tr>
<tr>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)">AAAAAAAAAAAAAAAAAAAAAAAAAA</td>
<td onMouseOver="MouseOver(this)" onMouseOut="MouseOut(this)"> </td>
</tr>
</table>
</body>
</html>
我想的到的结果是把onMouseOver或其他函数在动态加CELL时候如何付给CELL
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>
<script>
function InsertRow()
{
var tbl = document.getElementById("tbl");
var tr = tbl.insertRow();
}
function InsertCell(strID)
{
var tbl = document.getElementById("tbl");
if (tbl.rows.length)
{
var tr = tbl.rows[tbl.rows.length-1];
if (tr)
{
var td = tr.insertCell();
td.innerHTML = "Cell" + tr.cells.length; td.onmouseover = function ()
{
this.style.cursor = "hand";
this.style.color = "#FF0000";
} td.onmouseout = function ()
{
this.style.color = "#000000";
}
}
}
}
</script><BODY>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="tbl">
</table>
<input type="button" value="InsertRow" onclick="InsertRow()">
<input type="button" value="InsertCell" onclick="InsertCell()">
</BODY>
</HTML>
<html>
<head>
<title>动态添加表格内容</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language="JavaScript">
<!--
function InsertRow(strID)
{
var obj, objRows, objCells
var lngTDs
var i obj = document.getElementById(strID)
if (obj.rows.length == 0) {
lngTDs = 1
}
else {
lngTDs = obj.rows(0).cells.length
} objRows = obj.insertRow()
for (i=0; i<lngTDs; i++) {
InsertTD(objRows)
}
}function InsertCell(strID)
{
var obj, objCells
var lngTRs
var i obj = document.getElementById(strID)
lngTRs = obj.rows.length for (i=0; i<lngTRs; i++) {
InsertTD(obj.rows(i))
}
}function InsertTD(obj)
{
var objCells objCells = obj.insertCell()
objCells.innerHTML = "test " + Math.floor(Math.random() * 10000)
objCells.align = "center" objCells.onmouseover = function()
{
this.style.color = "red"
this.style.cursor = "hand"
}
objCells.onmouseout = function()
{
this.style.color = "black"
this.style.cursor = ""
}
}
//-->
</script>
</head><body>
<a href="javascript: InsertRow('tblEx')">INSERT TR</a> <a href="javascript: InsertCell('tblEx')">INSERT TD</a><br>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="tblEx">
</table>
</body>
</html>
<script>
function aa();
</script>
objCells.onmouseover =aa();
可以吗?