Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/69.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 使用Jquery搜索和隐藏文本_Javascript_Jquery_Html - Fatal编程技术网

Javascript 使用Jquery搜索和隐藏文本

Javascript 使用Jquery搜索和隐藏文本,javascript,jquery,html,Javascript,Jquery,Html,我想使用jQuery查找一些文本,但它存在,我想隐藏它 因此,如果:Yes存在,则应将其隐藏 HTML: 上面的Jquery隐藏了整个div,而不仅仅是:Yes 试试这个: $('.hide此标记:contains(“Yes”)).hide(); 或 $('span.hide this tag:contains(“Yes”)).hide(); 或 $('div.listing_detail span.hide此标记:contains(“Yes”)).hide() 客厅:是 厨房:否您不能将选

我想使用jQuery查找一些文本,但它存在,我想隐藏它

因此,如果
:Yes
存在,则应将其隐藏

HTML:

上面的Jquery隐藏了整个div,而不仅仅是
:Yes

试试这个:

$('.hide此标记:contains(“Yes”)).hide();
或
$('span.hide this tag:contains(“Yes”)).hide();
或
$('div.listing_detail span.hide此标记:contains(“Yes”)).hide()

客厅:
厨房:
您不能将选择器传递给
.hide()
。在对象上使用它:

$('.listing_detail:contains(“Yes”)).find('.hide this tag').hide()

客厅:
厨房:
因为您正在添加
。隐藏
在代码末尾,它正在选择所选元素(
),您需要的是如下内容:

if($('.listing_detail:contains("Yes")').length > 0){
     $('.hide-this-tag').hide(); //After you checked that the "Yes" exsists, hide the tag.
}

$('.listing_detail:contains(“Yes”)).find('.hide this tag').hide()hide不允许您说出隐藏、查找元素的内容。隐藏此标记然后隐藏itI我在上一个问题中给出了这个答案,为什么不在我的答案下面发表评论,以便我可以进一步帮助您?
 $('.listing_detail:contains("Yes")').hide('.hide-this-tag');
if($('.listing_detail:contains("Yes")').length > 0){
     $('.hide-this-tag').hide(); //After you checked that the "Yes" exsists, hide the tag.
}