<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>JavaScript拼接版</TITLE> <meta http-equiv="Content-Type" content="text/html; charset=GBK"> <script type="text/javascript" src="https://www.jb51.net/jquery-1.6.2.js"></script> <script type="text/javascript" src="https://www.jb51.net/jquery-rlutil-1.6.2.js"></script> <script type="text/javascript"> [color=green]/*onclick=prevMoveTrCommand(this,'show_table_id','td_num'); 这个地方千万不要带空格,否则乱码*/[/color] jQuery(document).ready(function(){ var str = ""; str += "<tr>"; str += "<td><input type='text' readonly='true' value='1' /></td>"; str += "<td>aaaaaaaaaa</td>"; str += "<td>@@@@@@@</td>"; str += "<td><input type='button' value='↑' onclick=prevMoveTrCommand(this,'show_table_id','td_num'); />"; str += " <input type='button' value='↓' onclick=nextMoveTrCommand(this,'show_table_id','td_num'); /></td>"; str += "<td>注释1</td>"; str += "</tr>"; str += "<tr>"; str += "<td><input type='text' readonly='true' value='2' /></td>"; str += "<td>bbbbbbbbbbbbb</td>"; str += "<td>#########</td>"; str += "<td><input type='button' value='↑' onclick=prevMoveTrCommand(this,'show_table_id','td_num'); />"; str += " <input type='button' value='↓' onclick=nextMoveTrCommand(this,'show_table_id','td_num'); /></td>"; str += "<td>注释2</td>"; str += "</tr>"; str += "<tr>"; str += "<td><input type='text' readonly='true' value='3' /></td>"; str += "<td>cccccccccccc</td>"; str += "<td>$$$$$$$$$$$$</td>"; str += "<td><input type='button' value='↑' onclick=prevMoveTrCommand(this,'show_table_id','td_num'); />"; str += " <input type='button' value='↓' onclick=nextMoveTrCommand(this,'show_table_id','td_num'); /></td>"; str += "<td>注释3</td>"; str += "</tr>"; str += "<tr>"; str += "<td><input type='text' readonly='true' value='4' /></td>"; str += "<td>ddddddddddddd</td>"; str += "<td>&&&&&&&&&&&&&</td>"; str += "<td><input type='button' value='↑' onclick=prevMoveTrCommand(this,'show_table_id','td_num'); />"; str += " <input type='button' value='↓' onclick=nextMoveTrCommand(this,'show_table_id','td_num'); /></td>"; str += "<td>注释4</td>"; str += "</tr>"; str += "<tr>"; str += "<td><input type='text' readonly='true' value='5' /></td>"; str += "<td>eeeeeeeeeeeeee</td>"; str += "<td>***************</td>"; str += "<td><input type='button' value='↑' onclick=prevMoveTrCommand(this,'show_table_id','td_num'); />"; str += " <input type='button' value='↓' onclick=nextMoveTrCommand(this,'show_table_id','td_num'); /></td>"; str += "<td>注释5</td>"; str += "</tr>"; $("#show_table_id").html(str); }); </script> </HEAD> <BODY> <table></table> </BODY> </HTML>
以上这篇jQuery实现table中的tr上下移动并保持序号不变的实例代码就是小编分享给大家的全部内容了,希望能给大家一个参考,也希望大家多多支持脚本之家。
您可能感兴趣的文章: