• 移动端模拟hover


    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,height=device-height,initial-scale=1.0,maximum-scale=1.0,minimum-scale=1.0,user-scalable=no">
    <title>移动端模拟hover</title>
    <style>
    html {
    font-size: 100px;
    }

    * {
    font-size: .16rem;
    }
    .content {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    overflow: auto;
    z-index: 10;
    background-color: #fff;
    -webkit-overflow-scrolling: touch;
    }
    .items {
    margin: 0;
    padding: 0;
    list-style: none;
    }
    .items li {
    box-sizing: border-box;
    line-height: .40rem;
    text-indent: 1em;
    border-bottom: 1px solid #e3e3e3;
    }

    .items li.active {
    background-color: #e3e3e3;
    }
    </style>
    </head>
    <body>
    <div class="content">
    <ul class="items">
    <li class="action-btn">item1</li>
    <li class="action-btn">item2</li>
    <li class="action-btn">item3</li>
    <li class="action-btn">item4</li>
    <li class="action-btn">item5</li>
    </ul>
    </div>

    <script src="http://dn.yunzhenshi.com/js/jquery-1.8.3.min.js"></script>
    <script>
    $(function () {
    //自定义tap
    $(document).on("touchstart", function (e) {
    if (!$(e.target).hasClass("disable")) $(e.target).data("isMoved", 0);
    });
    $(document).on("touchmove", function (e) {
    if (!$(e.target).hasClass("disable")) $(e.target).data("isMoved", 1);
    });
    $(document).on("touchend", function (e) {
    if (!$(e.target).hasClass("disable") && $(e.target).data("isMoved") == 0) $(e.target).trigger("tap");
    });

    //按钮点击效果
    $(document).on("touchstart", ".action-btn:not(.disable)", function (e) {
    var $this = $(this);
    var flag = true;
    //遍历子类
    $this.find("*").each(function () {
    //查看有没有子类触发过active动作
    if ($(this).hasClass("active")) flag = false;
    });
    //如果子类已经触发了active动作,父类则取消active触发操作
    if (flag) $this.addClass("active");

    });
    $(document).on("touchmove", ".action-btn:not(.disable)", function (e) {
    if ($(this).hasClass("active")) $(this).removeClass("active");
    });
    $(document).on("touchend", ".action-btn:not(.disable)", function (e) {
    if ($(this).hasClass("active")) $(this).removeClass("active");
    });

    });
    </script>
    </body>
    </html>

  • 相关阅读:
    图书管理系统
    关键路径
    最短路径

    最小生成树、最短路径
    Huffman编码
    LA 3401
    UVA 10881
    OI 刷题记录——每周更新
    4396: [Usaco2015 dec]High Card Wins
  • 原文地址:https://www.cnblogs.com/chengyunshen/p/7852731.html
Copyright © 2020-2023  润新知