html - 如何使用 jquery 隐藏或显示来自 th:each 的所有 div?
问题描述
首先,我很抱歉我的英语不好。
最近我正在使用 Spring Boot 做项目,我正在努力隐藏或显示由 th:each 创建的所有 div
<button class="category" onclick="showBar()">BAR</button>
<div id="barList" th:each="m: ${MERCH}" th:if="${m.cat.catId}==1">
<tr>
<p th:text="${m.getMName()}"></p><br>
<p th:text="${#numbers.formatInteger(m.price, 1, 'COMMA')}"></p>
</tr>
</div>
<script>
function showBar() {
$('#barList').hide();
}
</script>
这是我正在努力解决的 HTML 的一部分
我在 chrome 中的 devtool 上看到的是,第一个 div 似乎可以工作(style="display : none;" 已创建)但其他 div 出现后根本不起作用。
如何隐藏或显示从 th:each 出来的所有 div... TT
即使它不使用JQuery,也没关系。我只想隐藏所有。
再次为我的英语不好感到抱歉..希望你能理解..谢谢!
解决方案
推荐阅读
- python - 创建成本矩阵的更快方法
- php - 从 csv 文件计算 PHP 中的平均持续时间。平均时间似乎是 0 毫秒
- java - 处理 API 请求时出现 MismatchedInputException
- c# - C# - 如何传递列表
以委托为参数 - c++ - 是否可以在 C++ 中递归匹配整数模板参数?
- javascript - 我使用了 iframe,然后在使用 url 时出现了一些问题
- reactjs - 为什么将代码包装到“useEffect”中而没有第二个参数并且无需清理?
- sql - 如果另一个表中存在值,如何更新我的列?
- reporting-services - SSRS - 根据计算字段计算百分比
- pointers - 在结构字段中使用指针的区别