我已经在我的网页下面查找最接近span元素,并更改CSS类
<h5 class="text-center" id="findStore" style="width:260px">
<a data-toggle="collapse" data-parent="#accordion" href="#@item.ProductId" aria-expanded="true" aria-controls="@item.ProductId" style="color: @item.ProductTextColor;font-size:19px;text-decoration: none;" class="text-center">
<span class="text-center" style="margin-left:14%">FIND A STORE</span>
<span id="chevvy" class="glyphicon glyphicon-chevron-down pull-right"></span>
</a>
</h5>
我想发生的,当用户点击“查找商店”与编号chevvy跨度标签需要引用我需要更改类字形到山形了,我试着做下面的代码
$('h5:not(#nutritionInfo)').click(function() {
if ($(this).find('span').hasClass("glyphicon glyphicon-chevron-down")) {
$(this).find('span').removeClass("glyphicon glyphicon-chevron-down");
$(this).find('span').addClass("glyphicon glyphicon-chevron-up");
} else {
$(this).find('span').removeClass("glyphicon glyphicon-chevron-up");
$(this).find('span').addClass("glyphicon glyphicon-chevron-down");
}
});
但与上面的代码,它引用的“查找商店”并应用字形它显示两个。
我该如何引用Id chevvy的其他span标签并更改其上的雪佛龙?
一个是#chevvy项目只是那里的图标? – PavKR 2015-02-09 05:19:46
那么谁投票呢?任何解释为什么? – 2015-02-10 09:18:34