$(function() {
var $div_li = $(".tab-menu li");
$div_li.click(function() {
$(this).addClass("selected").siblings().removeClass("selected");
var index = $div_li.index(this);
$(".tab-content > li").eq(index).show().siblings().hide();
}).hover(function() {
$(this).addClass("hover");
},
function() {
$(this).removeClass("hover");
}) $("#tab-base").prev(".beside-post-ad").remove();
$('.project-list tbody tr').hover(function() {
$(this).find('td').addClass('hover');
},
function() {
$(this).find('td').removeClass('hover');
});
$('.project-list tbody tr').click(function() {
$(this).find('td').css('background-color', '#F2F6FE');
var href = $(this).find('a').attr('href'); {
window.location = href;
}
});
$('#archives .mon').each(function() {
var num = $(this).next().children('li').size();
var text = $(this).text();
$(this).html(text + '<em> ( ' + num + ' 篇文章 )</em><span></span>');
});
$('#archives .mon').click(function() {
$(this).next().slideToggle(250,
function() {
$(this).prev().find('span').toggleClass('arrow-up');
});
return false;
});
$('#list-view').click(function() {
$('.card-view').removeClass('card-view').addClass('list-view');
$('#card-view').removeClass('active');
$(this).addClass('active');
return false;
});
$('#card-view').click(function() {
$('.list-view').removeClass('list-view').addClass('card-view');
$('#list-view').removeClass('active');
$(this).addClass('active');
return false;
});
$('#sidebr-view').toggle(function() {
$(this).removeClass("active");
$('.sidebar').hide();
$('.sidebar-content').css({
"float": "none",
"width": "auto"
});
},
function() {
$(this).addClass("active");
$('.sidebar').show();
$('.sidebar-content').css({
"float": "left",
"width": "680px"
});
});
$('.widget_categories ul li .children, .archives-cat li .children').parent().css('border-bottom', 'none');
$('.sidebar ul li a').not('.sidebar .widget_ads ul li a').each(function() {
var atext = $(this).html();
$(this).html('<i>#</i>' + atext);
});
$('.nav-drop span').click(function() {
$(this).toggleClass('active');
$('#nav').toggle(0);
});
$(window).bind("resize", resizeWindow);
function resizeWindow(e) {
var newWindowWidth = $(window).width();
if (newWindowWidth > 580) {
$('#nav').css('display', 'block');
} else {
$('#nav').css('display', 'none');
}
}
$('.index .default-thumb').parent().parent('.thumb-index').css({
'width': 'auto',
'margin-right': '0'
}) $('.entry-content p img').parent('p').css('text-indent', '0');
$('.entry-content p img').removeAttr('height');
$(".show-select").change(function() {
if ($(".show-select").attr("value") == '文章评论') {
$('#commentnavi, #commenttit').show();
$('#comments-list ol').fadeIn();
$('.pinglisth').fadeOut();
$('.tracktit').hide();
} else {
$('#comments-list ol').fadeOut();
$('#commentnavi, #commenttit').hide();
$('.pinglisth').fadeIn();
$('.tracktit').show();
}
})
});
$("#container").delegate("#nav-below a", "click",
function() {
$(this).addClass("loading").text("loading...");
$.ajax({
type: "POST",
url: $(this).attr("href") + "#content",
success: function(data) {
result = $(data).find("#content .post-card");
nextHref = $(data).find("#nav-below a").attr("href");
$("#content").append(result.fadeIn(300));
$("#nav-below a").removeClass("loading").text("下一页 »");
if (nextHref != undefined) {
$("#nav-below a").attr("href", nextHref);
} else {
$("#nav-below").remove();
}
}
});
return false;
});
$("#container").delegate("#table-nav a", "click",
function() {
$(this).addClass("loading").text("loading...");
$.ajax({
type: "POST",
url: $(this).attr("href") + "#content",
success: function(data) {
result = $(data).find("#content .list-tr");
nextHref = $(data).find("#table-nav a").attr("href");
$(".project-list").append(result.fadeIn(300));
$("#table-nav a").removeClass("loading").text("下一页 »");
if (nextHref != undefined) {
$("#table-nav a").attr("href", nextHref);
} else {
$("#table-nav a").remove();
}
}
});
return false;
}); (function() {
var $backToTopTxt = "Top",
$backToTopEle = $('<div></div>').appendTo($("body")).text($backToTopTxt).attr("title", $backToTopTxt).click(function() {
$("html, body").animate({
scrollTop: 0
},
120);
}),
$backToTopFun = function() {
var st = $(document).scrollTop(),
winh = $(window).height(); (st > 0) ? $backToTopEle.show() : $backToTopEle.hide();
if (!window.XMLHttpRequest) {
$backToTopEle.css("top", st + winh - 166);
}
};
$(window).bind("scroll", $backToTopFun);
$(function() {
$backToTopFun();
});
})();
document.execCommand("BackgroundImageCache", false, true);
if ($.browser.msie && $.browser.version <= 9) {
$('input[placeholder]').each(function() {
var input = $(this);
$(input).val(input.attr('placeholder'));
$(input).focus(function() {
if (input.val() == input.attr('placeholder')) {
input.val('');
}
});
$(input).blur(function() {
if (input.val() == '' || input.val() == input.attr('placeholder')) {
input.val(input.attr('placeholder'));
}
});
});
}
20130628-ajax刷新-resize-change-delegate
关注我
我的微信公众号:前端开发博客,在后台回复以下关键字可以获取资源。

- 回复「小抄」,领取Vue、JavaScript 和 WebComponent 小抄 PDF
- 回复「Vue脑图」获取 Vue 相关脑图
- 回复「思维图」获取 JavaScript 相关思维图
- 回复「简历」获取简历制作建议
- 回复「简历模板」获取精选的简历模板
- 回复「加群」进入500人前端精英群
- 回复「电子书」下载我整理的大量前端资源,含面试、Vue实战项目、CSS和JavaScript电子书等。
- 回复「知识点」下载高清JavaScript知识点图谱
每日分享有用的前端开发知识,加我微信:caibaojian89 交流