在执行下面的代码时,当鼠标在其上(悬停)时,将显示“单击我”。
实际上我需要点击我显示到整个卡片(列表)。
null
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css" rel="stylesheet">
<div class="container">
<div class="card" style="width: 18rem;">
<ul class="list-group list-group-flush">
<a href="" class="btn btn-primary list-group-item">
<li class="">Click Here</li>
</a>
</ul>
<img src="" alt="Demo">
<ul class="list-group list-group-flush">
<li class="list-group-item">Know more about this feature</li>
</ul>
<div class="card-body">
<p class="card-text">Detailed Explanation of this feature</p>
</div>
</div>
</div>
null
如果卡体
仅在单击“了解此功能的更多信息”时才显示,我将不胜感激。
更改
<a href="" class="btn btn-primary list-group-item">
至
<a href="" class="btn btn-primary">
null
$(document).ready(function() {
$("li.list-group-item").click(function() {
$("div.card-body").toggleClass("hide");
});
});
.hide {
display: none;
}
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-9aIt2nRpC12Uk9gS9baDl411NQApFmC26EwAOH8WgZl5MYYxFfc+NcPb1dKGj7Sk" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.5.1.min.js" integrity="sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js" integrity="sha384-OgVRvuATP1z7JjHLkuOU7Xw704+h835Lr+6QL9UvYjZE3Ipu6Tp75j7Bh/kR0JKI" crossorigin="anonymous"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.0-2/css/all.min.css" rel="stylesheet">
<div class="container">
<div class="card" style="width: 18rem;">
<ul class="list-group list-group-flush">
<a href="" class="btn btn-primary ">
<!-- Add in task icon -->
<li class="">Click Here<span class="float-right"><i class="fas fa-tasks "></i></span></li>
</a>
</ul>
<img src="" alt="Demo">
<ul class="list-group list-group-flush">
<li class="list-group-item">Know more about this feature</li>
</ul>
<div class="card-body hide">
<p class="card-text">Detailed Explanation of this feature</p>
</div>
</div>
</div>