jquary根据td中按钮的元素属性删除tr行(删选出想删除的行)


删除没有蓝色按钮的行。

<html>

<tr>
                                <td>凉山彝族自治州分行</td>
                                <td>管理网</td>
                                <td>离行式ATM</td>
                                <td class="text-center">MSTP</td>
<td>西昌市西客站航天阳光</td>
                                <td class="text-center">建设中</td>
                                <td class="text-center">
<a title="详情" class="btn medium ui-state-default small" href="http://118.112.186.175:2222/super/index.php?c=my_network&amp;m=detail_page&amp;line_id=912">
<span class="button-content"><i class="glyph-icon icon-search-plus float-left"></i>详情&nbsp;</span>
                                    </a>
                                    <span class="btn medium ui-state-default">铺设线路中</span>&nbsp;<a class="btn medium bg-yellow" href="http://118.112.186.175:2222/super/index.php?c=my_network&amp;m=revocation_operate&amp;line_id=912"><span class="button-content">终止操作</span></a> 
                                </td>
                            </tr>

<tr>
                                <td>宜宾市分行</td>
                                <td>管理网</td>
                                <td>离行式ATM</td>
                                <td class="text-center">MSTP</td>
<td>四川省宜宾市南溪区古街</td>
                                <td class="text-center">建设中</td>
                                <td class="text-center">
<a title="详情" class="btn medium ui-state-default small" href="http://localhost/super/index.php?c=my_network&amp;m=detail_page&amp;line_id=896">
<span class="button-content"><i class="glyph-icon icon-search-plus float-left"></i>详情&nbsp;</span>
                                    </a>
                                    <a class="btn medium primary-bg" href="http://localhost/super/index.php?c=my_network&amp;m=line_verify_next&amp;line_id=896"><span class="button-content">网络验证完成</span></a>&nbsp;<a class="btn medium bg-yellow" href="http://localhost/super/index.php?c=my_network&amp;m=revocation_operate&amp;line_id=896"><span class="button-content">终止操作</span></a> 
                                </td>
                            </tr>

jquary

<script>
$(document).ready(function(){
$(".table tr").each(function(){
if(!$("a",this).hasClass("primary-bg")){
    $(this).hide();
   }
  });
});
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是使用jQuery动态创建每3个元素,并在每个元素上添加删除按钮的示例代码: HTML代码: ``` <div id="container"></div> ``` JavaScript代码: ```javascript // 定义一个数组,用于存储元素数据 var data = [ '元素1', '元素2', '元素3', '元素4', '元素5', '元素6', '元素7', '元素8', '元素9', ]; // 获取容器元素 var $container = $('#container'); // 遍历数据数组,创建元素并添加到容器 $.each(data, function(index, value) { // 创建元素 var $item = $('<div class="item"></div>').text(value); // 创建删除按钮 var $deleteBtn = $('<button class="delete-btn">删除</button>'); // 绑定删除按钮的点击事件 $deleteBtn.on('click', function() { // 在数据数组删除元素的数据 data.splice(index, 1); // 在页面删除元素 $item.remove(); }); // 将删除按钮添加到元素 $item.append($deleteBtn); // 将元素添加到容器 $container.append($item); // 如果是每的第3个元素,添加一个clearfix元素 if ((index + 1) % 3 === 0) { $container.append('<div class="clearfix"></div>'); } }); ``` CSS代码: ```css .item { float: left; width: 30%; margin-right: 3%; margin-bottom: 20px; border: 1px solid #ccc; padding: 10px; box-sizing: border-box; } .delete-btn { margin-left: 10px; } ``` 在上面的代码,我们首先定义了一个数组来存储元素的数据。然后,我们获取容器元素,并使用`$.each`函数遍历数据数组,创建每个元素并添加到容器。在创建元素时,我们还创建了一个删除按钮,并将其添加到元素。我们还绑定删除按钮的点击事件,以便在点击按钮时从数据数组删除元素的数据,并从页面删除元素。最后,我们还添加了一些CSS样式来指定元素删除按钮的样式。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值