隐藏 div 标签中没有唯一 ID 的文本
Hide a text in a div tag that has no unique ID
我需要帮助隐藏 "Silver=#" 和 "Manual=#" 文本。这些文本没有唯一 ID,所以我不知道如何隐藏这些文本。请帮忙。您可以在此处查看此特定页面 --> https://www.colonialacres.com/product-p/wbs-g8-y.htm
您可以尝试在 html 中使用 <!
,或者您可以使用 span 元素,然后添加 css { display:none;}
您可以从 DOM 中删除它们:
$('[itemprop="offers"]').contents().filter(function () {
return this.nodeType == 3 && this.data.match(/Silver|Manual/);
}).remove();
或者用 span 包裹它们并隐藏:
$('[itemprop="offers"]').contents().filter(function () {
return this.nodeType == 3 && this.data.match(/Silver|Manual/);
}).each(function(i, el) {
$(el).replaceWith($('<span>').text(el.data).css('display', 'none'));
});
试试这个:
$("SELECTOR:contains('STRING')").remove();
SELECTOR 与你的 div/element 相同,你想 select 使用你想隐藏的字符串(类似于 div table tbody tr td)和STRING 等于您要隐藏的字符串。
JSFiddle 示例:
我需要帮助隐藏 "Silver=#" 和 "Manual=#" 文本。这些文本没有唯一 ID,所以我不知道如何隐藏这些文本。请帮忙。您可以在此处查看此特定页面 --> https://www.colonialacres.com/product-p/wbs-g8-y.htm
您可以尝试在 html 中使用 <!
,或者您可以使用 span 元素,然后添加 css { display:none;}
您可以从 DOM 中删除它们:
$('[itemprop="offers"]').contents().filter(function () {
return this.nodeType == 3 && this.data.match(/Silver|Manual/);
}).remove();
或者用 span 包裹它们并隐藏:
$('[itemprop="offers"]').contents().filter(function () {
return this.nodeType == 3 && this.data.match(/Silver|Manual/);
}).each(function(i, el) {
$(el).replaceWith($('<span>').text(el.data).css('display', 'none'));
});
试试这个:
$("SELECTOR:contains('STRING')").remove();
SELECTOR 与你的 div/element 相同,你想 select 使用你想隐藏的字符串(类似于 div table tbody tr td)和STRING 等于您要隐藏的字符串。
JSFiddle 示例: