工作中的js总结

时间:2014-09-16 14:08:40   收藏:0   阅读:346

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);

原文:http://www.cnblogs.com/fangdx/p/3974710.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!