javascript - jQuery 切换按钮切换所有 div 而不是单个所需的
问题描述
我有几个“新闻卡”div,它们都可以通过按钮切换。我只需要切换按钮所在的“新闻卡片”的“卡片扩展”。
附言。这是我在这个网站上的第一个问题,所以请原谅任何不愉快的事情。
<script>
$(document).ready(function(){
$(".cardexpand").hide();
$(".expand").click(function(){
$(this).next(".cardexpand").toggle(1000);
});
});
</script>
<div class="newscard">
<img src="news1.jpg" class="img">
<div class="cardbody">
<p class="cardtitle">James Blyat does not associate with Vainglory players</p>
<p class="carddetails">Mar 29, 2019 • Gaming</p>
<button class="expand">Expand</button>
</div>
<div class="cardexpand">
<hr class="cardhr"></hr>
<p class="cardtext">
Vainglory is just anime of the gaming world and is
for weebs, he says. Vainglory is just anime of the gaming world and is
for weebs, he says.
</p>
</div>
</div>
解决方案
推荐阅读
- c++ - 关于 Leela Zero 的问题
- python - 打印 Python 字典时,在换行符 (\n) 前面出现附加 \
- asp.net-core - 为什么 ASP.Net Core Identity 使用字符串作为其主键属性?
- python - MacBook 上的不同 Python 路径在终端和 IDLE 中使用
- docker - 在 docker 中构建并运行您的图像 - 网络问题
- laravel - Laravel 路由使用 2 个模型和 2 个控制器
- ios - 选择器(SegmentedPickerStyle)中的选择效果不佳 - SwiftUI
- python - 无法将_keys 发送到输入字段,尽管能够找到它
- python-3.x - 如何从 h3 Selenium/Python 获取 href?
- javascript - Kotlin 中简单月相算法的问题