工作中的js总结

1、点击li下面匹配的内容块跟着一起改变

 

$(".dis-list li").bind("hover click", function () {
$this = $(this);
$this.addClass("active").siblings().removeClass("active");
$(".list-content li.item").eq($this.index()).addClass("on").siblings().removeClass("on");
});

2、升序降序

(function ($) {

$(document).ready(function () {

//调序
$("a[id^=‘ascent-‘]").first().hide();
$("a[id^=‘decline-‘]").last().hide();

//上升
$("a[id^=‘ascent-‘]").click(function (e) {
e.preventDefault();
var tr = $(this).parents("tr:first");
var id = tr.data("id");
var referenceId = tr.prev().data("id");

$.post($(this).attr("href"), { id: id, referenceId: referenceId }, function (data) {
var trBefore = tr.prev();
tr.insertBefore(trBefore);
$("a[id^=‘ascent-‘],a[id^=‘decline-‘]").show();
$("a[id^=‘ascent-‘]").first().hide();
$("a[id^=‘decline-‘]").last().hide();
});
});

//下降
$("a[id^=‘decline-‘]").click(function (e) {
e.preventDefault();
var tr = $(this).parents("tr:first");
var id = tr.data("id");
var referenceId = tr.next().data("id");

$.post($(this).attr("href"), { id: id, referenceId: referenceId }, function (data) {
var trAfter = tr.next();
tr.insertAfter(trAfter);
$("a[id^=‘ascent-‘],a[id^=‘decline-‘]").show();
$("a[id^=‘ascent-‘]").first().hide();
$("a[id^=‘decline-‘]").last().hide();
});
});

});

})(jQuery);

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。