首页 > 解决方案 > 消除

当它包含特定字符串时

问题描述

所以当他们的元素有这个时,我尝试删除一些 p html:pasdefichier。

我尝试使用此代码,但它不起作用!我精确的 p 已经添加了 ajax。我能怎么做 ?

$('.downloadfileexintegradedindb').removeByContent('pasdefichier');​
$('.downloadfileexintegradedindb:contains("pasdefichier")').hide();  //to hide
$('.downloadfileexintegradedindb:contains').find('p:contains("pasdefichier")').remove();

html代码:

<p class="downloadfileexintegradedindb" id="123456789" style="position: absolute; top: 36px; left: 123px;">pasdefichier</p>

标签: javascriptjqueryhtml

解决方案


您的第一行中有一个隐藏字符(请参阅https://www.soscisurvey.de/tools/view-chars.php),目前为您提供SyntaxError. 当我删除它时,我得到一个TypeError因为removeByContentundefined(也许是你的添加)。但是您可以只使用第二行来实现您想要remove的(代替hide):

$('.downloadfileexintegradedindb:contains("pasdefichier")').remove();  //to hide
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<p class="downloadfileexintegradedindb" id="123456789" style="position: absolute; top: 36px; left: 123px;">pasdefichier</p>


推荐阅读