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);
    });
  • 相关阅读:
    JAVA中对Cookie的操作
    springboot 快速开发的定制补充
    centos7 安装 mysql5.7 版本(全)
    springboot redis-cache 自动刷新缓存
    spring-data-redis-cache 使用及源码走读
    Redis 相关功能和实用命令(五)
    Redis 集群(三)
    Redis 主从,哨兵,集群实战(四)
    redis 主从复制和哨兵模式(二)
    导出 mysql 数据到 redis
  • 原文地址:https://www.cnblogs.com/EnzoDin/p/6438174.html
Copyright © 2011-2022 走看看