我已經在我的網頁下面查找最接近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