惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园_首页
I
InfoQ
The Register - Security
The Register - Security
L
LangChain Blog
H
Help Net Security
The GitHub Blog
The GitHub Blog
S
Schneier on Security
博客园 - 【当耐特】
W
WeLiveSecurity
Attack and Defense Labs
Attack and Defense Labs
IT之家
IT之家
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Google DeepMind News
Google DeepMind News
The Cloudflare Blog
H
Heimdal Security Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Y
Y Combinator Blog
雷峰网
雷峰网
N
Netflix TechBlog - Medium
Security Archives - TechRepublic
Security Archives - TechRepublic
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
L
Lohrmann on Cybersecurity
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
The Exploit Database - CXSecurity.com
P
Privacy & Cybersecurity Law Blog
G
GRAHAM CLULEY
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
V
Visual Studio Blog
博客园 - 聂微东
PCI Perspectives
PCI Perspectives
Last Week in AI
Last Week in AI
A
Arctic Wolf
宝玉的分享
宝玉的分享
T
The Blog of Author Tim Ferriss
S
Secure Thoughts
T
Threat Research - Cisco Blogs
GbyAI
GbyAI
云风的 BLOG
云风的 BLOG
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
SegmentFault 最新的问题
SecWiki News
SecWiki News
月光博客
月光博客
大猫的无限游戏
大猫的无限游戏
Schneier on Security
Schneier on Security
P
Proofpoint News Feed
博客园 - Franky
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
AI
AI
Engineering at Meta
Engineering at Meta

博客园 - 努力前上

button按回车触发后台 - 努力前上 - 博客园 Connectionstrings - 努力前上 - 博客园 [C#]包含DataSet类的XML架构怎么不自动生成CS文件了(XSD和CS文件不能合并) Asp.Net 备份和恢复SQL SERVER 数据库 提取HTML代码中文字的C#函数 (转) - 努力前上 - 博客园 危险字符过滤的类(最新完善版)(1) Tree使用 常用的一些javascript小技巧(转) 利用TreeView控件动态生成无限级树(续:通过绑定动态xml文件)(转) - 努力前上 - 博客园 利用TreeView控件动态生成无限级树(转) - 努力前上 - 博客园 Microsfot.Web.UI.WebControls.TreeView JavaScript控制方法研究(转) (二)execCommand()函数可用参数大解析 JavaScript--execCommand指令集 js 技巧杂引(转) HTML代码过滤函数 DataGrid 颜色交替 DataGrid双击事件 javascript调用webservice [垃圾猪]防盗链IHttpHandler源码
JS 无刷新排序
努力前上 · 2005-12-26 · via 博客园 - 努力前上

JS 无刷新排序 比较实用的脚本。

<html>
<head>
<script>
function order(){
var it=event.srcElement;
var table=it;
var i,j,k;
var t1,t2;
if(it.tagName=="TH"){
    i
=it.cellIndex;
    it.title
=it.title=="asc"?"desc":"asc";
    
while(table.tagName!="TABLE")table=table.parentElement;
    
if(table.rows.length<3)return true;
    
for(j=1;j<table.rows.length;j++){
        
for(k=j+1;k<table.rows.length;k++){
            
if(it.title=="asc"?parseFloat(table.rows[k].cells[i].innerText)<parseFloat(table.rows[j].cells[i].innerText):parseFloat(table.rows[k].cells[i].innerText)>parseFloat(table.rows[j].cells[i].innerText))
            table.rows[j].swapNode(table.rows[k]);
        }

    }

}

}

</script>
</head>
<body>

<table border="1">
<thead onclick="order()">
<th>Item 1</th><th>Item 2</th><th>Item 3</th><th>Item 4</th>
</thead>
<tr><td>12.3</td><td>423</td><td>86.83</td><td>1.213</td></tr>
<tr><td>2</td><td>434</td><td>5.334</td><td>.234</td></tr>
<tr><td>33</td><td>43</td><td>5.223</td><td>8.73</td></tr>
<tr><td>21.3</td><td>234</td><td>52.34</td><td>.666</td></tr>
<tr><td>33.4</td><td>59</td><td>67.2</td><td>.426</td></tr>
</table>

</body>
</html>