从带有索引的表中删除特定的td

 手机用户2502892083 发布于 2023-02-11 14:39

我正在寻找答案,但是找不到希望解决的问题。

我想从表中删除一些td。td还没有分类或ID。

Blabla 25,2 27,6 22,4 23,0 26,3 28,5 28,0

这里我的jQuery代码非常简单:

jQuery('table tbody tr td').each(function () {
    if (jQuery(this).index() < 3) {
        alert(jQuery(this).text()); // display the good td value
        jQuery(this).remove(); // remove all td
    }
 });

我认为,如果j Query(this).text返回正确的值jQuery(this),则循环中的当前td也是如此。但是jQuery(this).remove()删除所有td,我不明白为什么。如果有人可以向我解释.. :)

撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有