posts - 431,  comments - 344,  trackbacks - 0
公告
 Don't Repeat Yourself
座右铭:you can lose your money, you can spent all of it, and if you work hard you get it all back. But if you waste your time, you're never gonna get it back.
公告本博客在此声明部分文章为转摘,只做资料收集使用。


微信: szhourui
QQ:109450684
Email
lsi.zhourui@gmail.com
<2008年1月>
303112345
6789101112
13141516171819
20212223242526
272829303112
3456789

留言簿(15)

随笔分类(1019)

文章分类(3)

文章档案(21)

收藏夹

Link

好友博客

最新随笔

搜索

  •  

积分与排名

  • 积分 - 855853
  • 排名 - 47

最新评论

阅读排行榜

<html>
  <head>
    <title>Sort.html</title>
 <script type="text/javascript">
  function compareTRs(oTR1, oTR2) {
   var sValue1 = oTR1.cells[0].firstChild.nodeValue;
   var sValue2 = oTR2.cells[0].firstChild.nodeValue;
   return sValue1.localeCompare(sValue2);
  }
  function sortTable(sTableID) {
   var oTable = document.getElementById(sTableID);
   var oTBody = oTable.tBodies[0];
   var colDataRows = oTBody.rows;
   var aTRs = new Array;
   
   for (var i = 0; i < colDataRows.length; i++) {
    aTRs.push(colDataRows[i]);
   }
   
   aTRs.sort(compareTRs);
   
   var oFragment = document.createDocumentFragment();
   for (var i = 0; i < aTRs.length; i++) {
    oFragment.appendChild(aTRs[i]);
   }
   
   oTBody.appendChild(oFragment);
  }
 </script>
  </head>
 
  <body>
    This is my HTML page. <br>
    <table border="1" id="tblSort">
     <thead>
      <tr>
       <th onclick="sortTable('tblSort')" style="cursor:pointer">Last Name</th>
      </tr>
     </thead>
     <tbody>
      <tr>
       <td>Smith</td>
      </tr>
      <tr>
       <td>Johnson</td>
      </tr>
      <tr>
       <td>Henderson</td>
      </tr>
      <tr>
       <td>Williams</td>
      </tr>
      <tr>
       <td>Gilliams</td>
      </tr>
      <tr>
       <td>Walker</td>
      </tr>
     </tbody>
    </table>
  </body>
</html>
posted on 2008-01-24 11:49 周锐 阅读(369) 评论(0)  编辑  收藏 所属分类: HTMLJavaScript

只有注册用户登录后才能发表评论。


网站导航:
博客园   IT新闻   Chat2DB   C++博客   博问