zoukankan      html  css  js  c++  java
  • 巧用目标元素

     直接上代码:

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>Document</title>
    </head>
    <script src="http://lib.sinaapp.com/js/jquery/1.9.1/jquery-1.9.1.min.js"></script>
    <body>
    <div id="outer1" class = "haofa"style="background:#099">
    <p class="inner" style="background:#9C0">click inner</p>
    </div>
    <div id="outer2" class = "haofa"style="background:#099">
    <p class="inner" style="background:#9C0">click inner</p>
    </div>
    <div id="outer3" class = "haofa"style="background:#099">
    <p class="inner" style="background:#9C0">click inner</p>
    </div>
    <div id="outer4" class = "haofa"style="background:#099">
    <p class="inner" style="background:#9C0">click inner</p>
    </div>
    <div id="outer5" class = "haofa"style="background:#099">
    <p class="inner" style="background:#9C0">click inner</p>
    </div>
    <div id="outer6" class = "haofa"style="background:#099">
    <p class="inner" style="background:#9C0">click inner</p>
    </div>

    <script type="text/javascript">

    $('.inner').click(function(e){
    $('.haofa').has(e.target).remove();
    })
    </script>
    </body>
    </html>

    ......

    通过$('.haofa').has(e.target).remove(),通过有无目标元素,找含有目标元素的父元素,从而删除;

    “我相当乐意花一天的时间通过编程把一个任务实现自动化,除非这个任务手动只需要10秒钟就能完成”
  • 相关阅读:
    Qt笔记之 信号和槽
    Qt笔记之 坐标系
    Qt笔记之 QPushButton
    点双连通
    bzoj 2179 FFT快速傅立叶
    bzoj 4128 矩阵求逆
    bzoj 3924 点分
    bzoj 1076 状态压缩最优期望
    bzoj 3143 随机游走
    bzoj 4084 双旋转字符串
  • 原文地址:https://www.cnblogs.com/flxy-1028/p/6043697.html
Copyright © 2011-2022 走看看