當(dāng)點(diǎn)擊加入購(gòu)物車或立即購(gòu)買時(shí)獲取到口味、包裝的選中的data-id值了?<div class="theme-options"> <div class="cart-title">口味</div> <ul> <li class="sku-line selected" id="taste" data-id="1">原味</li> <li class="sku-line" id="taste" data-id="2">黑糖</li> </ul> </div><div class="theme-options"> <div class="cart-title">包裝</div> <ul id="test"> <li class="sku-line selected" data-id="1">單人份<i></i></li> <li class="sku-line" data-id="2">禮品包<i></i></li> </ul> </div> <li> <div class="clearfix tb-btn tb-btn-buy theme-login"> <a id="LikBuy" title="點(diǎn)此按鈕到下一步確認(rèn)購(gòu)買信息" href="#">立即購(gòu)買</a> </div></li> <li> <div class="clearfix tb-btn tb-btn-basket theme-login"> <a id="LikBasket" title="加入購(gòu)物車"><i></i>加入購(gòu)物車</a> </div> </li>現(xiàn)在只能獲取口味的data-id,如何點(diǎn)擊加入購(gòu)物車獲取到口味的data-id、包裝的data-id的值$('#LikBasket').on('click', function() {var id = $('.sku-line.selected').data('id');console.log(id);
})
如何獲取li標(biāo)簽當(dāng)中的data-id的值了?
一只萌萌小番薯
2018-07-03 13:17:00