jquery lavaLamp 高亮选中部分
下面这段jquery代码,涉及到each(), attr(), text(), $(this), parent(), addClass(), css选择符,组合选择符等知识。
var thisurl = window.location.href;
var thispath = window.location.pathname;
$(function() {
// $(".lavaLamp > li > a").each(function(index) { alert($(this).text()); $(this).attr("href", 'a.html'); } );
$(".lavaLamp a").each(function() {
// alert($(this).text());
// $(this).attr("href", 'a.html');
// alert($(this).attr("href") + ' : ' + thisurl);
if ($(this).attr("href") == thisurl) {
if (thispath.indexOf("/", 1) > 0) {
$(this).parent().parent().parent().addClass("current-cat");
} else {
$(this).parent().addClass("current-cat");
}
// alert($(this).attr('class'));
}
} );
}
);
$(function(){$(".lavaLamp").lavaLamp({ fx: "backout", speed: 700 })});
0 个评论
894 次阅读