【发布时间】:2020-05-01 10:06:15
【问题描述】:
我想在我的页面上使用code for the card,但我需要“阅读更多”链接才能转到另一个页面,而不是关闭卡的描述。不幸的是,我不擅长 jQuery。
$(document).ready(function() {
var zindex = 10;
$("div.card").click(function(e) {
e.preventDefault();
var isShowing = false;
if ($(this).hasClass("show")) {
isShowing = true
}
if ($("div.cards").hasClass("showing")) {
// a card is already in view
$("div.card.show").removeClass("show");
if (isShowing) {
// this card was showing - reset the grid
$("div.cards").removeClass("showing");
} else {
// this card isn't showing - get in with it
$(this).css({
zIndex: zindex
}).addClass("show");
}
zindex++;
} else {
// no cards in view
$("div.cards").addClass("showing");
$(this).css({
zIndex: zindex
}).addClass("show");
zindex++;
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="cards">
<div class="card">
<img class="card__image" src="https://source.unsplash.com/300x225/?wave" alt="wave" />
<div class="card-title">
<a href="#" class="toggle-info btn">
<span class="left"></span>
<span class="right"></span>
</a>
<h2>
Card title
<small>Image from unsplash.com</small>
</h2>
</div>
<div class="card-flap flap1">
<div class="card-description">
This grid is an attempt to make something nice that works on touch devices. Ignoring hover states when they're not available etc.
</div>
<div class="card-flap flap2">
<div class="card-actions">
<a href="https://www.behance.net/gallery/72373861/BBDO-Ecuador" class="btn">Read more</a>
</div>
</div>
</div>
</div>
</div>
【问题讨论】:
-
您不能在 href
<a href="#" class="btn">Read more</a>中添加指向您页面的链接吗? -
@CarstenLøvboAndersen 我添加了,但它不起作用。当您单击“阅读更多”链接时,卡的描述将关闭,并且不会指向我需要它的页面。这就是我寻求帮助的原因