$('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);
});

 

相关文章:

  • 2022-02-20
  • 2021-05-08
  • 2021-06-03
  • 2021-09-23
  • 2022-12-23
  • 2021-05-23
  • 2022-02-07
猜你喜欢
  • 2021-05-31
  • 2022-12-23
  • 2022-12-23
  • 2022-02-01
  • 2021-09-07
  • 2022-12-23
相关资源
相似解决方案