JS的表格控制例子.
刚刚问的问题.
解决后到这显宝来了^^.
兼谢过以下诸位.
<html>
<body>
<form>
<!--源表-->
<table>
<tr>
<td>
<table id="t0" border="1" height="200" width="200">
<caption>联系人</caption>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">飞鸟</a></td>
<td>flybird@snai.edu</td>
</tr>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">笑点点 </a></td>
<td>笑点点 </td>
</tr>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">colashu</a></td>
<td>colashu </td>
</tr>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">zergling</a></td>
<td>onlydream@eastday.com</td>
</tr>
</table>
</td>
<td>
<!--目的表1(空)-->
<table id="t1" border="1" height="200" width="200">
<caption>收信人</caption>
</table>
</td>
</tr>
</table>
<script>
function moveThis()
{
//取的事件的来源.
var obj=window.event.srcElement
//取的事件所在的行也是要移动的.
var trObj=getPrt(obj,"TR");
//取得要移动到的目的地.
var toObj=getTo(obj).children[1];
//移动
toObj.insertBefore(trObj);
}
function getPrt(o,str)
{
if(o.tagName==str)
return o;
else if(o.tagName=="BODY")
return null;
else
return getPrt(o.parentElement,str)
}
function getTo(o)
{
var srco=getPrt(o,"TABLE");
if(srco.id=="t0")
return t1;
else
return t0;
}
</script>
</form>
</body>
</html>
解决后到这显宝来了^^.
兼谢过以下诸位.
<html>
<body>
<form>
<!--源表-->
<table>
<tr>
<td>
<table id="t0" border="1" height="200" width="200">
<caption>联系人</caption>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">飞鸟</a></td>
<td>flybird@snai.edu</td>
</tr>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">笑点点 </a></td>
<td>笑点点 </td>
</tr>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">colashu</a></td>
<td>colashu </td>
</tr>
<tr>
<td><a href="javaScript:void(0)" onclick="moveThis()">zergling</a></td>
<td>onlydream@eastday.com</td>
</tr>
</table>
</td>
<td>
<!--目的表1(空)-->
<table id="t1" border="1" height="200" width="200">
<caption>收信人</caption>
</table>
</td>
</tr>
</table>
<script>
function moveThis()
{
//取的事件的来源.
var obj=window.event.srcElement
//取的事件所在的行也是要移动的.
var trObj=getPrt(obj,"TR");
//取得要移动到的目的地.
var toObj=getTo(obj).children[1];
//移动
toObj.insertBefore(trObj);
}
function getPrt(o,str)
{
if(o.tagName==str)
return o;
else if(o.tagName=="BODY")
return null;
else
return getPrt(o.parentElement,str)
}
function getTo(o)
{
var srco=getPrt(o,"TABLE");
if(srco.id=="t0")
return t1;
else
return t0;
}
</script>
</form>
</body>
</html>
- 没有相关文章
- 没有评论