检测最接近或父div [英] Detecting closest or parent div

查看:88
本文介绍了检测最接近或父div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下脚本:

http://jsfiddle.net/oshirowanen/pALBV/

我如何使其更具动态性,所以如果屏幕上的按钮数量未知,则不必为每个按钮手动指定按钮点击次数,因为最终结果是,容器以及容器内容将作为数据库生成.

How do I make this more dynamic, so I do not have to manually specify the button clicks for each button if the number of buttons on screens is unknown as in the end result, the containers along with the container content will be database generated.

目前,我仅在jquery脚本中指定了button_2.

At the moment, I have only specified button_2 in jquery script.

推荐答案

尝试一下:

$(function() {
    $(':button').click(function() {
        $(this).closest('.container').fadeOut('slow', function() {
            $(this).remove();
        });
    });
});

这篇关于检测最接近或父div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆