I am currently adding a feature to a genealogy website I am currently working on which is based on the Webtrees open source software.
So originally, the software allows the user to press the individual node to expand/compress its content. And that works through the following code:
TreeViewHandler.prototype.expandBox = function(j, i) {
if (jQuery(i.target).hasClass("tv_link")) {
return !1
}
j = jQuery(j, this.treeview);
var p = j.parent(),
o = j.attr("abbr"),
n = this,
l, k;
if (p.hasClass("detailsLoaded")) {
k = p.find(".collapsedContent"), l = p.find(".tv_box:not(.collapsedContent)")
} else {
l = j;
k = j.clone();
p.append(k.addClass("collapsedContent").css("display", "none"));
var m = this.loadingImage.find("img").clone().addClass("tv_box_loading").css("display", "block");
j.prepend(m);
n.updating = !0;
n.setLoading();
j.load(n.ajaxUrl + "getDetails&pid=" + o, function() {
"function" === typeof CB_Init && CB_Init();
j.css("width", n.zoom / 100 * n.boxExpandedWidth + "px");
m.remove();
p.addClass("detailsLoaded");
n.setComplete();
n.updating = !1
})
}
j.hasClass("boxExpanded") ? (l.css("display", "none"), k.css("display", "block"), j.removeClass("boxExpanded")) : (l.css("display", "block"), k.css("display", "none"), l.addClass("boxExpanded"));
this.getSize();
return !1
};
What I'm trying to do is I'm trying to make the button I placed on the top left, which is to expand/compress ALL boxes in one click work. The one in showing/hiding females already work.
$(document).ready(function(){
var female = false
$(".tv_hidefemales").click(function(){
if (female == false) {
$(".tvF").hide();
female = true
} else {
$(".tvF").show();
female = false
}
});
$(".tv_expandCompress").click(function(){
tvHandler.expandBox($(".tv"), 0);
});
});
我发现我可以利用循环的jQuery .click()函数。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.