gpt4 book ai didi

jquery - show().parent().show() - 这是怎么回事?

转载 作者:行者123 更新时间:2023-12-03 22:48:17 27 4
gpt4 key购买 nike

我不明白当你这样做一连串 .show() 时会发生什么。我也没有编写这段代码,也不知道如何弄清楚这里发生了什么。因此就有了这个问题。

// Remove favorite category
$(".FavoriteRemove").click(function() {
var cat = $(this).parents(".Category"); //the parent of the clicked item is the category/bundle
var catid = $(this).attr("catid"); //the id tag on the clicked item is the BundleID
$.post($(this).attr("href"), function() { //the href tag is the post URL for adding a favorite
cat.remove(); //here we remove the category/bundle

//*** WHAT IS THIS DOING? v
$(".Category[catid=" + catid + "]").show().parent().show();
//*** NO THAT UP THERE ^
if ($(".FavoriteCategories div").length == 0)
$(".FavoriteCategories").hide();
//bindCategories();
});
return false;
});

有人能解释一下这是什么意思吗?我知道目标是“类别”类,其属性与 ID 匹配,但我不明白函数链的含义。

谢谢。

最佳答案

  • 第一show()(docs)具有类 Category 的元素,以及具有给定变量值的 catid 属性。
  • 然后使用 parent()(docs) 向上遍历到其父级。方法。
  • 然后show()(docs)家长。

“显示”意味着将其 display 样式属性从 none 设置为其初始(或默认)值,例如 block

关于jquery - show().parent().show() - 这是怎么回事?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4893607/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com