3
我得到了这段代码,一切都好,功能齐全。 当我点击时,我需要改变心脏颜色的选项。Boostrap改变颜色点击
现在:
点击灰色的空心脏将充分灰色充分的心脏
我需要: 点击灰色的空心脏将全力冲满心脏
$(function($) {
$(document).on('click', '.box-btn', function(event) {
var target = $(event.target).closest('.wrapper');
target.find('.glyphicon').toggleClass('glyphicon-heart-empty glyphicon-heart');
\t
});
});
.box-btn {
float:left;
background: transparent;
font-size: 53px;
color: #4D4E56;
font-weight: 300;
cursor: pointer;
border-radius: 2px;
line-height: 0.5;
border: none;
\t outline:none;
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="submit" class="box-btn"><span class="glyphicon glyphicon-heart-empty" aria-hidden="true"></span></button>
出于某种原因,如果我使用(这一点),而不是目标,没有什么happend,如果我使用的目标,并添加以下的toogle红,则心脏是灰色的再次,你有什么想法可以造成这种情况吗? –
@MR.Don'tknow我改变为* this *以使您的工作成为您提供的标记的例子。通过该目标您正在搜索不存在的元素包装器。如果你可以用更多的代码做一个小提琴,我可以帮你 – DaniP