【问题标题】:show list according to letter clicked in pug from mongodb根据从 mongodb 在 pug 中单击的字母显示列表
【发布时间】:2018-05-05 08:09:40
【问题描述】:

上一个问题:show list according to the letter clicked in jade data retrieve from mongodb

如果我点击任何字母,它会相应地显示品牌。

当用户点击 other brand 选项时会出现问题,该选项必须显示不以字母开头的品牌 A-Z

我不知道该怎么做。

有人可以帮我吗?

【问题讨论】:

标签: javascript html node.js pug mean-stack


【解决方案1】:

我刚刚改了之前的答案,见:https://codepen.io/anon/pen/ooqmNX

我添加了 show all 和其他选项来列出,但是这些项目还有额外的 attribute 命名为 type 可以使用。

var type = $(this).attr("type")
if (type) {
    if (type == "all") {
        $(".brands h4").show();//show all
    } else if (type == "other") {
        $(".brands h4").hide();//hide all
        $(".brands h4").each(function() {
            var brandName = $(this).attr("name")
            if (!brandName.toLowerCase()[0].match(/[a-z]/i))//if name not starts with letter
                $(this).show();
        });
    }
    return;
}

【讨论】:

  • 再次感谢先生。
猜你喜欢
  • 2018-05-03
  • 2019-09-16
  • 1970-01-01
  • 1970-01-01
  • 2022-06-10
  • 1970-01-01
  • 2022-01-23
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多