最近在对之前的项目进行功能增加又因为是老项目所以用的是js和jquery
项目的需要是点击表头的按钮进行排序
按钮是在阿里矢量图中找的点击上箭头升序排列点击下箭头降序
下面是整理的代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>1</title>
<link rel="stylesheet" href="./font_qoy0poj5ux/iconfont.css" />
<script src="./jquery-1.12.4.min.js"></script>
<script src="./font_qoy0poj5ux/iconfont.js"></script>
<style type="text/css">
body {
font-size: 12px;
line-height: 25px;
}
tr {
height: 25px;
}
th {
font-size: 14px;
border-bottom: solid 1px #dddddd;
background-color: #eeeeee;
border: solid 1px;
}
td {
font-size: 12px;
text-align: center;
border: solid 1px;
}
.name {
position: relative;
}
.icon-shang1 {
position: absolute;
font-size: 12%;
top: 12%;
height: 12px;
line-height: 12px;
}
.icon-xia1 {
line-height: 12px;
height: 12px;
bottom: 4%;
position: absolute;
font-size: 12%;
}
</style>
</head>
<body>
<table
border="0"
id="tbl"
style="border:solid 1px #DDDDDD;width:360px;"
cellpadding="0"
cellspacing="0"
>
<thead>
<tr>
<th id="th0" class="name">
name
<span class="iconfont icon-shang1" onclick="a(this)"></span>
<span class="iconfont icon-xia1" onclick="bottom()"></span>
</th>
<th id="th1">muscle</th>
<th id="th2">smart</th>
<th id="th3">city</th>
</tr>
</thead>
<tbody>
<tr>
<td class