$('ul').on("click","li#left",function(){
currentProvince = $(this).text().replace(/[0-9]/ig,"");
$(this).siblings().removeClass('choose');
$(this).addClass('choose');
refreshTypeByProvince(currentProvince);
refreshOrderCountByProvinceAndOrderType(currentProvince,currentOrderType);
refreshUserOrderInfoByProvinceAndOrderType(currentProvince,currentOrderType);
});
$('ul').on("click","li#bottom",function(){
currentOrderType = $(this).text().replace(/[0-9]/ig,"");
$(this).siblings().removeClass('choose');
$(this).addClass('choose');
refreshOrderCountByProvinceAndOrderType(currentProvince,currentOrderType);
refreshUserOrderInfoByProvinceAndOrderType(currentProvince,currentOrderType);
});
頁面中有多個<ul>,現在想要不同的<ul>中<li>標簽點擊相應不同的事件。
同一<ul>下的<li>設置相同的id,上述代碼中的left、bottom即為<li>的id。
這樣就能各自響應各自的事件了。
0228更新
感覺一個ul下邊的每個li都設置一樣的id不太好。。,還是給ul加個id吧。。。如下
$('yourULID').on("click","li",function(){
currentOrderType = $(this).text().replace(/[0-9]/ig,"");
$(this).siblings().removeClass('choose');
$(this).addClass('choose');
refreshOrderCountByProvinceAndOrderType(currentProvince,currentOrderType);
refreshUserOrderInfoByProvinceAndOrderType(currentProvince,currentOrderType);
});
