如何防止儿童被带走

How to prevent removal of a child?

本文关键字:带走 何防止      更新时间:2023-09-26

我有以下代码:

var o = true;
$('a#filter').click(function () {
    if(o){
        $('.heading').append(''
        <div id="fil">'
            <div class="row">'
                <div class="span12">'
                    <div class="content" style="padding-bottom:0;margin-top:0px; text-align:center; min-height:0px;background:-moz-linear-gradient(center top , #fafafa 0%, #e9e9e9 100%) repeat scroll 0 0 rgba(0, 0, 0, 0);background:-webkit-linear-gradient(top, #fafafa 0%, #e9e9e9 100%);">'
                        <?php echo '<a href="http://njace-cc.montclair.edu/admin/users/manage.php">All</a> ' . $letters; ?>'
                    </div>'
                </div>'
            </div>'
        </div>');
        o = false;
        $('#cls').html("▲");
    }
    else{
        $('.heading').children("#fil").remove();
        o = true;
        $('#cls').html("▼");
    }
});

场景是:

  1. 用户点击链接(id=filter)
  2. 用户得到一个包含a-Z字母的div
  3. 如果用户点击一封信,那么一个表就会被过滤掉

问题是,在GET操作(单击一个字母)之后,div将消失(被删除),我希望在GET操作之后(单击字母)仍然显示该div。

我尝试使用以下代码触发php标签中的点击功能:

echo '<script>$("a#filter").trigger("click");</script>';

但没有奏效。

知道吗?

更改

$('.heading').children("#fil").remove();

$('.heading').children("#fil").empty();
$(document).ready(function() {  
    if(window.location.search.length){
        $("a#filter").trigger("click");
    }
});