当点击加入购物车或立即购买时获取到口味、包装的选中的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> <li class="sku-line" id="taste" data-id="3">蜂蜜</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> <li class="sku-line" data-id="3">豪华包装<i></i></li> </ul> </div> <li> <div class="clearfix tb-btn tb-btn-buy theme-login"> <a id="LikBuy" title="点此按钮到下一步确认购买信息" href="#">立即购买</a> </div> </li> <li> <div class="clearfix tb-btn tb-btn-basket theme-login"> <a id="LikBasket" title="加入购物车"><i></i>加入购物车</a> </div> </li>
现在只能获取口味的data-id,如何点击加入购物车获取到口味的data-id、包装的data-id的值
程序代码:
$('#LikBasket').on('click', function() { var id = $('.sku-line.selected').data('id'); console.log(id); })