8.第8章 -8-彻头彻尾的不正经(2/2)
<li data-num="19"></li>
<li data-num="20"></li>
<li data-num="21"></li>
<li data-num="22"></li>
<li data-num="23"></li>
<li data-num="24"></li>
<li data-num="25"></li>
<li data-num="26"></li>
<li data-num="27"></li>
<li data-num="28"></li>
<li data-num="29"></li>
<li data-num="30"></li>
<li data-num="31"></li>
</ul>
</div>
</div>
</div>
<div class="setbox">
<div class="setli">
<ul>
<li>
<label>背景</label>
<div class="setbg">
</div>
</li>
<li><label>字体</label>
<div class="setfontf">
</div>
</li>
<li><label>字号</label>
<div class="setfontsize">
<input class="sizenum" type="text" value="18">
<a class="cut" href="#" onclick="fontcut()">-
<a class="add" href="#" onclick="fontadd()">+
</div>
</li>
</ul>
</div>
</div>
<div class="foot">
<div class="copyright">
<div>
</div>
<p>copyright 2021 </p>
</div>
</div>
<div class="modelbg"></div>
<script src="
<script>tongji();</script>
<script>
//排序
var btnc = 0
$(".sorting a").click(function () {
btnc++
if (btnc == 1) {
$(".sorting a").eq(1).hide()
$(".sorting a").eq(0).show()
} else {
$(".sorting a").eq(0).hide()
$(".sorting a").eq(1).show()
btnc = 0
}
})
var domarr = [];
var htmlarr = [];
var allarr = [];
//从小到大排序
function smalltobig() {
allarr.sort(function (a, b) { return a.name - b.name });
appenddom();
}
//从大到小排序
function bigtosmall() {
allarr.sort(function (a, b) { return b.name - a.name });
appenddom()
}
//取出所有li的data-num属性放进数组
getdom()
function getdom() {
$(#catalog ul li).each(function (m) {
domarr[m] = $(this).attr("data-num");
htmlarr[m] = $(this).html();
})
for (var i = 0; i < domarr.length; i++) {
var activesubjectsobject = {};
for (var j = 0; j < htmlarr.length; j++) {
if (i == j) {
activesubjectsobject.name = domarr[i];
activesubjectsobject.value = htmlarr[j];
allarr.push(activesubjectsobject);
}
}
}
// console.log(allarr.length)
}
//铺数据
function appenddom() {
$("#catalog ul").html("")
for (i = 0; i < allarr.length; i++) {
$(#catalog ul).append(
`<li data-num=${allarr[i].name}>${allarr[i].value}</li>`
);
}
}
</script>
</body>
</html>
83中文网最新地址www.83zws.com