jQuery(document).ready(function() {
jQuery(".page-contents div").hide();
// Show chosen div, and hide all others
jQuery("a").click(function (e) {
//e.preventDefault();
jQuery("#" + jQuery(this).attr("class")).show().siblings('div').hide();
});
});
有人可以解释我如何修改此代码,以便它为所选链接添加“活动”类,以及它是如何工作的?非常感谢您提前
答案 0 :(得分:0)
以下代码将active
类添加到点击链接:
jQuery(document).ready(function() {
jQuery(".page-contents div").hide();
// Show chosen div, and hide all others
jQuery("a").click(function (e) {
//e.preventDefault();
//jQuery("#" + jQuery(this).attr("class")).show().siblings('div').hide();
jQuery(this).addClass("active");
});
});