资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
很弱的js表格换行效果(表格移动行)
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <p> </p> <p> </p> <p> </p> <table width="300" style="font-size:12px" border="3" align="center" cellpadding="5" cellspacing="3" bordercolor="#FFFFFF" bgcolor="#99CC66" id="table1"> <tr> <td width="25%" align="center" bgcolor="#FFFFCC">1</td> <td width="25%" align="center" bgcolor="#FFFFCC">11</td> <td width="25%" align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveUp(this)">上移</a></td> <td width="25%" align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveDown(this)">下移</a></td> </tr> <tr> <td align="center" bgcolor="#FFFFCC">2</td> <td align="center" bgcolor="#FFFFCC">22</td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveUp(this)">上移</a></td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveDown(this)">下移</a></td> </tr> <tr> <td align="center" bgcolor="#FFFFCC">3</td> <td align="center" bgcolor="#FFFFCC">33</td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveUp(this)">上移</a></td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveDown(this)">下移</a></td> </tr> <tr> <td align="center" bgcolor="#FFFFCC">4</td> <td align="center" bgcolor="#FFFFCC">44</td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveUp(this)">上移</a></td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveDown(this)">下移</a></td> </tr> <tr> <td align="center" bgcolor="#FFFFCC">5</td> <td align="center" bgcolor="#FFFFCC">55</td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveUp(this)">上移</a></td> <td align="center" bgcolor="#FFFFCC"><a href="javascript:void(0)" _ewebeditor_ta_href="javascript%3Avoid(0)" onclick="moveDown(this)">下移</a></td> </tr> </table> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20language%3D%22javascript%22%20type%3D%22text%2Fjavascript%22%3E%20%0D%0A%3C!--%20%0D%0Afunction%20cleanWhitespace(element)%7B%20%0D%0A%2F%2F%E9%81%8D%E5%8E%86element%E7%9A%84%E5%AD%90%E8%8A%82%E7%82%B9%20%0D%0Afor(var%20i%3D0%3Bi%3Celement.childNodes.length%3Bi%2B%2B)%20%0D%0A%7B%20%0D%0Avar%20node%3Delement.childNodes%5Bi%5D%20%0D%0Aif(node.nodeType%3D%3D3%20%26%26%20!%2F%5Cs%2F.test(node.nodeValue))%20%0D%0Anode.parentNode.removeChild(node)%3B%20%0D%0A%7D%20%0D%0A%7D%20%0D%0A%2F%2F%E8%8E%B7%E5%BE%97%E8%A1%A8%E6%A0%BC%E5%AF%B9%E8%B1%A1%20%0D%0Avar%20_table%3Ddocument.getElementById(%22table1%22)%3B%20%0D%0AcleanWhitespace(_table)%3B%20%0D%0A%2F%2F%E4%BD%BF%E8%A1%A8%E6%A0%BC%E8%A1%8C%E4%B8%8A%E7%A7%BB%EF%BC%8C%E6%8E%A5%E6%94%B6%E5%8F%82%E6%95%B0%E4%B8%BA%E9%93%BE%E6%8E%A5%E5%AF%B9%E8%B1%A1%20%0D%0Afunction%20moveUp(_a)%7B%20%0D%0A%2F%2F%E9%80%9A%E8%BF%87%E9%93%BE%E6%8E%A5%E5%AF%B9%E8%B1%A1%E8%8E%B7%E5%8F%96%E8%A1%A8%E6%A0%BC%E8%A1%8C%E7%9A%84%E5%BC%95%E7%94%A8%20%0D%0Avar%20_row%3D_a.parentNode.parentNode%3B%20%0D%0A%2F%2F%E5%A6%82%E6%9E%9C%E4%B8%8D%E6%98%AF%E7%AC%AC%E4%B8%80%E8%A1%8C%20%E4%BA%A4%E6%8D%A2%E9%A1%BA%E5%BA%8F%20%0D%0Aif(_row.previousSibling)swapNode(_row%2C_row.previousSibling)%3B%20%0D%0A%7D%20%0D%0A%2F%2F%E4%BD%BF%E8%A1%A8%E6%A0%BC%E8%A1%8C%E4%B8%8B%E7%A7%BB%20%E6%8E%A5%E6%94%B6%E5%8F%82%E6%95%B0%E4%B8%BA%E9%93%BE%E6%8E%A5%E5%AF%B9%E8%B1%A1%20%0D%0Afunction%20moveDown(_a)%7B%20%0D%0A%2F%2F%E9%80%9A%E8%BF%87%E9%93%BE%E6%8E%A5%E5%AF%B9%E8%B1%A1%E8%8E%B7%E5%8F%96%E8%A1%A8%E6%A0%BC%E8%A1%8C%E7%9A%84%E5%BC%95%E7%94%A8%20%0D%0Avar%20_row%3D_a.parentNode.parentNode%3B%20%0D%0A%2F%2F%E5%A6%82%E6%9E%9C%E4%B8%8D%E6%98%AF%E6%9C%80%E5%90%8E%E4%B8%80%E8%A1%8C%20%E5%88%99%E4%B8%8E%E4%B8%8B%E4%B8%80%E8%A1%8C%E4%BA%A4%E6%8D%A2%E9%A1%BA%E5%BA%8F%20%0D%0Aif(_row.nextSibling)%20swapNode%20(_row%2C_row.nextSibling)%3B%20%0D%0A%7D%20%0D%0A%2F%2F%E5%AE%9A%E4%B9%89%E9%80%9A%E7%94%A8%E7%9A%84%E5%87%BD%E6%95%B0%E4%BA%A4%E6%8D%A2%E4%B8%A4%E4%B8%AA%E8%8A%82%E7%82%B9%E7%9A%84%E4%BD%8D%E7%BD%AE%20%0D%0Afunction%20swapNode(node1%2Cnode2)%7B%20%0D%0A%2F%2F%E8%8E%B7%E5%8F%96%E7%88%B6%E8%8A%82%E7%82%B9%20%0D%0Avar%20_parent%3Dnode1.parentNode%3B%20%0D%0A%2F%2F%E8%8E%B7%E5%8F%96%E4%B8%A4%E4%B8%AA%E8%8A%82%E7%82%B9%E7%9A%84%E7%9B%B8%E5%BA%94%E4%BD%8D%E7%BD%AE%20%0D%0Avar%20_t1%3Dnode1.nextSibling%3B%20%0D%0Avar%20_t2%3Dnode2.nextSibling%3B%20%0D%0A%2F%2F%E5%B0%86node2%E6%8F%92%E5%85%A5%E5%88%B0%E5%8E%9F%E6%9D%A5node1%E7%9A%84%E4%BD%8D%E7%BD%AE%20%0D%0Aif(_t1)_parent.insertBefore(node2%2C_t1)%3B%20%0D%0Aelse%20_parent.appendChild(node2)%3B%20%0D%0A%2F%2F%E5%B0%86node1%E6%8F%92%E5%85%A5%E5%88%B0%E5%8E%9F%E6%9D%A5ndoe2%E7%9A%84%E4%BD%8D%E7%BD%AE%20%0D%0Aif(_t2)_parent.insertBefore(node1%2C_t2)%3B%20%0D%0Aelse%20_parent.appendChild(node1)%3B%20%0D%0A%7D%20%0D%0A%2F%2F--%3E%20%0D%0A%3C%2Fscript%3E"> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程