tableSort.class.js
复制代码 代码如下:
/* * 表格名不能为空,可为已获取的对象或名字 * 表头名默认为:tag * 通过自行编写接口可实现不同的触发排序方式 * * 作者:Auntion * E-mail:Auntion@Gmail.com * OICQ:82874972 * * 日期:2007年04月22日 - 测试 - 待修正 */ var tableSort= function(element,tagName,upStyle,downStyle){this.table= (typeof(element) == 'string') ? TAGDom.fromId(element) : element;this.td = this.table.getElementsByTagName("td"); this.hName= (tagName.length<1) ? "tag" : tagName;this.rows = this.table.rows;this.byUp = (upStyle == undefined) ? "DescUp" : upStyle ;this.byDown = (downStyle == undefined) ? "DescDown" : downStyle ;var totalTd = [];var totalNr = [];var totalTag= [];this.tempCellIndex; this.tempStatus = {};var setAllTag = function(){ for(var i = 0; i < this.td.length; i++){if(this.td[i].className === this.hName) totalTag.push(this.td[i]);}}.bind(this);var getStatus = function(tagName){this.tempStatus[tagName] = (this.tempStatus[tagName] == true) ? false : true;for(tags in this.tempStatus){if(tags == tagName) return this.tempStatus[tags];else delete this.tempStatus[tags];}}.bind(this);var changeShow = function(cellIn,status){for(var i=0; i<totalTag.length; i++){if(totalTag[i].cellIndex == cellIn){if(status == true) totalTag[i].className = this.byUp;else if(status == false) totalTag[i].className = this.byDown;}else{totalTag[i].className = this.hName;}}}.bind(this);var startSort = function(status){for (var i = totalNr[this.tempCellIndex].length - 1; i > 0; i--){for (var j = 0; j < i; ++j){if ( (status == true) ? totalNr[this.tempCellIndex][j] > totalNr[this.tempCellIndex][j + 1] : totalNr[this.tempCellIndex][j] < totalNr[this.tempCellIndex][j + 1] ){var temp = totalNr[this.tempCellIndex][j + 1];totalNr[this.tempCellIndex][j + 1] = totalNr[this.tempCellIndex][j];totalNr[this.tempCellIndex][j] = temp;for(var n=0; n<totalNr.length; n++){if(n != this.tempCellIndex){var temps = totalNr[n][j+1];totalNr[n][j + 1] = totalNr[n][j];totalNr[n][j] = temps;}}}}};InsertContect();}.bind(this);var InsertContect = function(){ for(var i=0; i<totalTd.length; i++){for(var j=0; j<totalTd[i].length; j++){totalTd[i][j].innerHTML = totalNr[i][j];}};totalTd.length = 0;totalNr.length = 0;};this.init = function(status){for(var i=0; i<(this.td.length/this.rows.length); i++){totalTd[i] = new Array();totalNr[i] = new Array();for(var j=0; j<this.rows.length; j++){if(this.rows[j].cells[i].className !== this.hName){totalTd[i][j-1] = this.rows[j].cells[i];if(IsNumber(this.rows[j].cells[i].innerHTML) == true){totalNr[i][j-1] = parseInt(this.rows[j].cells[i].innerHTML);}else{totalNr[i][j-1] = this.rows[j].cells[i].innerHTML;}}}}startSort(status);} /********************************************************************************************************************************/ /**通过点击标签触发排序事件**/ //public: 通过默认鼠标事键触发 (interface example)(设置用户接口的范例) this.toTagStart = function(){ setAllTag(); //获取标签 for(var i=0; i<totalTag.length; i++){ totalTag[i].sIndex = function(cIndex){ this.tempCellIndex=cIndex }.bind(this); //设置列index totalTag[i].gStatus = function(values){ return getStatus(values) }; //获取与设置状态 totalTag[i].ceShow = function(i,s){ changeShow(i,s) }; //改变显示的东西 totalTag[i].stSort = function(status){ this.init(status) }.bind(this); //初始化 totalTag[i].onselectstart = function(){ return false }; //点击不选中文字 totalTag[i].onclick = function(){ this.sIndex(this.cellIndex); this.status = this.gStatus(this.firstChild.nodeValue); this.ceShow(this.cellIndex,this.status); this.stSort(this.status); } } } }
Language.ext.js
复制代码 代码如下:
/* * By Auntion QQ:82874972 Blog:Auntion@blogbus.com Email:Auntion@Gmail.com 请勿删除此部分注释.谢谢! ver date-2007-02-01 * */ var isIe = /msie/i.test(navigator.userAgent); var TAGDom = { fromId: function(i){ return document.getElementById(i); }, fromName: function(i){ return document.getElementById(i); }, fromClass: function(className,baseId) { this.fatherId = null; if(!baseId){ this.fatherId = document; }else{ this.fatherId = DOM.fromId(baseId); } var basic = fatherId.getElementsByTagName("*") || document.all; var child = null; var classNames = null; var aggregate = []; for (var i = 0; i < basic.length; i++) { child = basic[i]; classNames = child.className.split(" "); for (var j = 0; j < classNames.length; j++) { if (classNames[j] == className) { aggregate.push(child); break; } } } return aggregate; } }; function externalStyle (element, target) { this.setReturn; if (element.currentStyle){ this.setReturn = element.currentStyle[target]; }else if (window.getComputedStyle){ this.setReturn = getComputedStyle (element,"").getPropertyValue(target); } return this.setReturn; } String.prototype.toInt = function(){ return parseInt(this.replace(/[a-zA-Z]+/,'')); } String.prototype.trim = function(){ return this.replace(/(^\s*)|(\s*$)/g, ""); } Function.prototype.bind = function(e) { var source = this; return function() { return source.apply(e,arguments); } } function IsNumber(_str){ var tmp_str = _str.trim(); var pattern = /^(- ¦\+)?\d+(\d+)?$/; return pattern.test(tmp_str); }
使用实例_1.htm
复制代码 代码如下:
<html> <head> <title>Auntion - TableSort 测试交流</title> <style type="text/css"> #bodys{ border-top:1px solid #0099FF; border-left:1px solid #0099FF; } #bodys td { border-bottom:1px solid #0099FF; border-right:1px solid #0099FF; font-size:12px; height:22px; line-height:22px; text-align:left; padding-left:10px; background:#DFEFFF; color:#666666; } #bodys td.tag { background:#95D5FF; color:#333333; font-weight:900; height:28px; line-height:28px; cursor:pointer; } #bodys td.DescUp { background:#FFFFCC url("byUp.gif") no-repeat right 6px; color:#333333; font-weight:900; height:28px; line-height:28px; cursor:pointer; } #bodys td.DescDown { background:#FFFFCC url("byDown.gif") no-repeat right 6px; color:#333333; font-weight:900; height:28px; line-height:28px; cursor:pointer; } </style> <script language="javascript" type="text/javascript" src="Language.ext.js"></script> <script language="javascript" type="text/javascript" src="tableSort.class.js"></script> </head> <body> <table border="0" cellspacing="0" cellpadding="0" id="bodys"> <tr> <td width="45" class="tag">选择</td> <td width="50" class="tag">数字</td> <td width="50" class="tag">字母</td> <td width="80" class="tag">名字</td> <td width="150" class="tag">地址</td> <td width="80" class="tag">时间</td> </tr> <tr> <td><input type="checkbox" checked></td> <td>1</td> <td>a</td> <td>谢诗圆</td> <td>http://www.php.cn/;/td> <td>2007-12-16</td> </tr> <tr> <td><input type="checkbox" checked></td> <td>4</td> <td>c</td> <td>auntion</td> <td>http://www.php.cn/;/td> <td>2006-12-06</td> </tr> <tr> <td><input type="checkbox"></td> <td>3</td> <td>b</td> <td>疯狂的石头</td> <td>http://www.php.cn/;/td> <td>2007-03-12</td> </tr> <tr> <td><input type="checkbox"></td> <td>3.2</td> <td>d</td> <td>谢某人</td> <td>http://www.php.cn/;/td> <td>2000-01-01</td> </tr> <tr> <td><input type="checkbox" checked></td> <td>5</td> <td>f</td> <td>小小强</td> <td>http://www.php.cn/;/td> <td>2008-12-31</td> </tr> <tr> <td><input type="checkbox"></td> <td>7</td> <td>e</td> <td>疯狂的man</td> <td>http://www.php.cn/;/td> <td>2006-11-12</td> </tr> <tr> <td><input type="checkbox"></td> <td>71</td> <td>g</td> <td>小强</td> <td>http://www.php.cn/;/td> <td>2002-08-23</td> </tr> <tr> <td><input type="checkbox" checked></td> <td>8</td> <td>h</td> <td>王庆</td> <td>http://www.php.cn/;/td> <td>1999-08-25</td> </tr> </table> <script language="javascript" type="text/javascript"> var apply = new tableSort("bodys","tag"); apply.toTagStart(); //这里将使用已经定义的一种默认触发方式. </script> </body> </html>
以上就是Auntion-TableSort javascript类文件_javascript技巧的内容,更多相关内容请关注PHP中文网(www.php.cn)!

Python和JavaScript的主要区别在于类型系统和应用场景。1.Python使用动态类型,适合科学计算和数据分析。2.JavaScript采用弱类型,广泛用于前端和全栈开发。两者在异步编程和性能优化上各有优势,选择时应根据项目需求决定。

选择Python还是JavaScript取决于项目类型:1)数据科学和自动化任务选择Python;2)前端和全栈开发选择JavaScript。Python因其在数据处理和自动化方面的强大库而备受青睐,而JavaScript则因其在网页交互和全栈开发中的优势而不可或缺。

Python和JavaScript各有优势,选择取决于项目需求和个人偏好。1.Python易学,语法简洁,适用于数据科学和后端开发,但执行速度较慢。2.JavaScript在前端开发中无处不在,异步编程能力强,Node.js使其适用于全栈开发,但语法可能复杂且易出错。

javascriptisnotbuiltoncorc; saninterpretedlanguagethatrunsonenginesoftenwritteninc.1)javascriptwasdesignedAsalightweight,解释edganguageforwebbrowsers.2)Enginesevolvedfromsimpleterterterpretpreterterterpretertestojitcompilerers,典型地提示。

JavaScript可用于前端和后端开发。前端通过DOM操作增强用户体验,后端通过Node.js处理服务器任务。1.前端示例:改变网页文本内容。2.后端示例:创建Node.js服务器。

选择Python还是JavaScript应基于职业发展、学习曲线和生态系统:1)职业发展:Python适合数据科学和后端开发,JavaScript适合前端和全栈开发。2)学习曲线:Python语法简洁,适合初学者;JavaScript语法灵活。3)生态系统:Python有丰富的科学计算库,JavaScript有强大的前端框架。

JavaScript框架的强大之处在于简化开发、提升用户体验和应用性能。选择框架时应考虑:1.项目规模和复杂度,2.团队经验,3.生态系统和社区支持。

引言我知道你可能会觉得奇怪,JavaScript、C 和浏览器之间到底有什么关系?它们之间看似毫无关联,但实际上,它们在现代网络开发中扮演着非常重要的角色。今天我们就来深入探讨一下这三者之间的紧密联系。通过这篇文章,你将了解到JavaScript如何在浏览器中运行,C 在浏览器引擎中的作用,以及它们如何共同推动网页的渲染和交互。JavaScript与浏览器的关系我们都知道,JavaScript是前端开发的核心语言,它直接在浏览器中运行,让网页变得生动有趣。你是否曾经想过,为什么JavaScr


热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章

热工具

WebStorm Mac版
好用的JavaScript开发工具

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能

mPDF
mPDF是一个PHP库,可以从UTF-8编码的HTML生成PDF文件。原作者Ian Back编写mPDF以从他的网站上“即时”输出PDF文件,并处理不同的语言。与原始脚本如HTML2FPDF相比,它的速度较慢,并且在使用Unicode字体时生成的文件较大,但支持CSS样式等,并进行了大量增强。支持几乎所有语言,包括RTL(阿拉伯语和希伯来语)和CJK(中日韩)。支持嵌套的块级元素(如P、DIV),

Dreamweaver CS6
视觉化网页开发工具

安全考试浏览器
Safe Exam Browser是一个安全的浏览器环境,用于安全地进行在线考试。该软件将任何计算机变成一个安全的工作站。它控制对任何实用工具的访问,并防止学生使用未经授权的资源。