我在圖庫中設置了一系列鏈接,我需要一種向用戶顯示顏色的方法。目前,顏色名稱存儲在圖庫中圖像鏈接的href標題中。獲取href標題並點擊更改
<div class="select-option swatch-wrapper selected" data-attribute="pa_luxcraft-2" data-value="redblack">
<a href="#" style="width:32px;height:32px;" title="Red/Black" class="swatch-anchor"><img src="/ay/wp-content/uploads/2017/01/Center-Table-Red-Black-32x32.jpg" alt="thumbnail" class="wp-post-image swatch-photopa_luxcraft-2_ swatch-img" width="32" height="32" data-pin-nopin="true"></a>
</div>
在這種情況下,它是紅/黑的顏色
每次圖像被點擊它被分配之類的「選擇」
我知道我能拿到冠軍了簡單變量的
var title = $(this).attr('title');
但我不確定如何得到它時選擇的類被應用。
你的意思'$(本).hasClass( '選擇')'? –