zoukankan      html  css  js  c++  java
  • js多个<ul>相应不同的点击事件

    $('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);
    });
  • 相关阅读:
    收藏夹
    获取某个元素在页面上的偏移量
    React多行文本溢出处理(仅针对纯文本)
    react
    CDN初学搭建(ats)
    linux查看cpu、内存、版本信息
    MySQL5.6版本性能调优my.cnf详解
    How to install cacti on centos 6
    win10安装.net3.5 报错解决
    CentOS6.5安装Cacti统计图乱码解决
  • 原文地址:https://www.cnblogs.com/EnzoDin/p/6438174.html
Copyright © 2011-2022 走看看