<div class="table-responsive" id="Bk_table" style="display:none;">
<table class="table table-hover table-bordered">
<thead>
<tr>
<th>
<div class="out">
<b>板块</b>
<em>维度</em>
</div>
</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
deleteLie: function () { //删除一列
var index = $(this).parent().index();
for (var i = 0; i < $(".table tr").length; i++) {
$($(".table tr")[i]).children().eq(index).remove();
}
if ($(".table tr").length == 1 && $(".table tr").eq(0).children().length == 1) {
$("#Bk_table").hide();
$(".blankShow").show();
}
},
deleteOneline: function () { //删除一行
$(this).parent().parent().remove();
if ($(".table tr").length == 1 && $(".table tr").eq(0).children().length == 1) {
$("#Bk_table").hide();
$(".blankShow").show();
}
},
addOneBk: function () { //增加一列
if ($("#Bk_table").is(":hidden")) {
$("#Bk_table").show();
}
if ($(".blankShow").is(":visible")) {
$(".blankShow").hide();
}
var firstLie = ' <th class="hovershow"><span class="font_zs" style="display:none">中弘西岸3</span>' +
'<input type="text" class="form-control getPrevalue" placeholder="填写板块名称" />' +
'<a class="glyphicon glyphicon-remove bkdelete delete_lie"></a></th>';
$(".table>thead>tr").eq(0).append(firstLie);
var otherLie = '<td><input type="text" class="form-control" value="" placeholder="1-5之间数字" ' +
'onkeyup="if(isNaN(value)||parseFloat(value)>5||parseFloat(value)<1)execCommand(\'undo\')"' +
'onafterpaste="if(isNaN(value)||parseFloat(value)>5||parseFloat(value)<1)execCommand(\'undo\')" /></td>';
$(".table>tbody>tr").append(otherLie);
},
addWd: function () { //增加一行
if ($("#Bk_table").is(":hidden")) {
$("#Bk_table").show();
}
if ($(".blankShow").is(":visible")) {
$(".blankShow").hide();
}
var Wdhtml_1 = '<tr>' +
' <th scope="row" class="hovershow">' +
'<span class="font_zs t1" style="display:none">维度三</span>' +
'<input type="text" class="form-control getPrevalue" placeholder="填写维度名称" />' +
'<a class="glyphicon glyphicon-remove bkdelete deleteoneline"></a>' +
'</th>';
var Wdhtml_2 = "";
var LieLength = $(".table>thead>tr").children().length - 1;
if (LieLength > 0) {
for (var i = 0; i < LieLength; i++) {
Wdhtml_2 = Wdhtml_2 + ' <td><input type="text" class="form-control" value="" placeholder="1-5之间数字" onkeyup="if(isNaN(value)||parseFloat(value)>5||parseFloat(value)<1)execCommand(\'undo\')" onafterpaste="if(isNaN(value)||parseFloat(value)>5||parseFloat(value)<1)execCommand(\'undo\')" /></td>';
}
}
var Wdhtml_3 = '</tr>';
var allWd = Wdhtml_1 + Wdhtml_2 + Wdhtml_3;
$(".table>tbody").append(allWd);
}
$(function(){
//存入点击列的每一个TD的内容;
var aTdCont = [];
//点击列的索引值
var thi = 0
//重新对TR进行排序
var setTrIndex = function(tdIndex){
for(i=0;i<aTdCont.length;i++){
var trCont = aTdCont[i];
$("tbody tr").each(function() {
var thisText = $(this).children("td:eq("+tdIndex+")").text();
if(thisText == trCont){
$("tbody").append($(this));
}
});
}
}
//比较函数的参数函数
var compare_down = function(a,b){
return a-b;
}
var compare_up = function(a,b){
return b-a;
}
//比较函数
var fSort = function(compare){
aTdCont.sort(compare);
}
//取出TD的值,并存入数组,取出前二个TD值;
var fSetTdCont = function(thIndex){
$("tbody tr").each(function() {
var tdCont = $(this).children("td:eq("+thIndex+")").text();
aTdCont.push(tdCont);
});
}
//点击时需要执行的函数
var clickFun = function(thindex){
aTdCont = [];
//获取点击当前列的索引值
var nThCount = thindex;
//调用sortTh函数 取出要比较的数据
fSetTdCont(nThCount);
}
//点击事件绑定函数
$("th").toggle(function(){
thi= $(this).index();
clickFun(thi);
//调用比较函数,降序
fSort(compare_up);
//重新排序行
setTrIndex(thi);
},function(){
clickFun(thi);
//调用比较函数 升序
fSort(compare_down);
//重新排序行
setTrIndex(thi);
})
})
<style type="text/css">
*{ margin:0px; padding:0px;}
table{
border-collapse:collapse;}
table td{
border:1px solid #036;
text-align:center;
}
thead tr th{
cursor:pointer;
background:#066;
color:#FFFFFF;
}
thead tr th:hover{
background:#369;}
</style>
<table class="tabSort" width="546" height="300" border="0" align="center" cellpadding="0" cellspacing="0">
<thead>
<tr>
<th scope="col">名称</th>
<th scope="col">价格</th>
<th scope="col">地址</th>
<th scope="col">备注</th>
<th scope="col">时间</th>
</tr>
</thead>
<tbody>
<tr>
<td>商品1</td>
<td>10.5</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品2</td>
<td>11.3</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品3</td>
<td>9.8</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品4</td>
<td>12.6</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品5</td>
<td>13.9</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品6</td>
<td>18</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品7</td>
<td>21.3</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品8</td>
<td>6.5</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td>商品9</td>
<td>7.4</td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有