jquery, delete some specific child nodes

来源:互联网 发布:零基础学大数据算法 编辑:程序博客网 时间:2024/06/16 14:27

delete all the non-button child nodes of $('campaign-labels')

<div class="col-sm-7" id="campaign-labels">  <button type="button" class="btn btn-default" data-toggle="modal" data-target=".campaign-modal-lg">    <span class="glyphicon glyphicon-plus" aria-hidden="true"> </span>  </button>  <span class="label label-default">Souhu app test</span>  <span class="label label-primary">test for sohu mobile</span>  <span class="label label-info">搜狐测试-勿动</span></div>

$('#campaign-labels').contents().filter(function(){return this.type != 'button';}).remove();


0 0