隐藏表格或基于表格中的文本的文本

发布于 2025-01-06 01:52:39 字数 401 浏览 4 评论 0原文

我必须隐藏一个看起来像这样的桌子:

<table style="width:100%;">
<tr>
    <td style="color: #929292; font-size: 11px; text-align: center;">
    &copy; 1999 - 2012 MyCO&trade; Marketing Technologies&trade;, MyApp<sup>&reg;</sup>
    </td>
</tr>
</table>

我已经尝试了几乎所有的方法,但似乎没有任何效果。当我尝试各种包含时,我收到一个空错误,如果我包含全文,我收到一个字符串错误。

I have to hide a table that looks like this:

<table style="width:100%;">
<tr>
    <td style="color: #929292; font-size: 11px; text-align: center;">
    © 1999 - 2012 MyCO™ Marketing Technologies™, MyApp<sup>®</sup>
    </td>
</tr>
</table>

I have tried just about everything, nothing seems to work. When I tried the various contains, I get a null error and if I include the full text I get a string error.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

如果没结果 2025-01-13 01:52:39
    jQuery.noConflict();
    jQuery(document).ready(function() {
        var cells = $("table td");
        var str = "© 1999 - 2012 PTI™ Marketing Technologies™, MarcomCentral<sup>®</sup>";
        var encodedText = $("<div></div>").html(str).text();

        cells.each(function(i, element) {
            var jqElement = $(element);
            if (jqElement.text().indexOf(encodedText) != -1)
                jqElement.hide();
        });
    });
    jQuery.noConflict();
    jQuery(document).ready(function() {
        var cells = $("table td");
        var str = "© 1999 - 2012 PTI™ Marketing Technologies™, MarcomCentral<sup>®</sup>";
        var encodedText = $("<div></div>").html(str).text();

        cells.each(function(i, element) {
            var jqElement = $(element);
            if (jqElement.text().indexOf(encodedText) != -1)
                jqElement.hide();
        });
    });
两相知 2025-01-13 01:52:39

这是一种基于您提供的 HTML 的解决方案:

$(function() {
    var text = 'MyApp'; // set the text string
    $('table tr td:contains('+ text +')') // find the td that contains the text
    .parents('table') // select the parent table
    .first() // reduce results to first table
    .hide(); // hide it
});

Here is one solution based on the HTML you provided:

$(function() {
    var text = 'MyApp'; // set the text string
    $('table tr td:contains('+ text +')') // find the td that contains the text
    .parents('table') // select the parent table
    .first() // reduce results to first table
    .hide(); // hide it
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文