javascript - 消除
当它包含特定字符串时
问题描述
所以当他们的元素有这个时,我尝试删除一些 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>
解决方案
您的第一行中有一个隐藏字符(请参阅https://www.soscisurvey.de/tools/view-chars.php),目前为您提供SyntaxError
. 当我删除它时,我得到一个TypeError
因为removeByContent
是undefined
(也许是你的添加)。但是您可以只使用第二行来实现您想要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>
推荐阅读
- php - Laravel:缓存存储 [predis] 未在 Illuminate\Cache\CacheManager.php 中定义
- c# - ViewModel ArgumentOutOfRangeException 中的 Navigation.PopModalAsync()
- angular - angular 6模块延迟加载路由器路径混乱
- c++ - C++ 查找已排序字符串中的重复字符
- python - 访问基类变量
- mysql - 在“meta_value”中搜索值时加快 WordPress 查询
- php - Laravel 5.6:创建数据库和几个模式
- javascript - jQuery - 显示/隐藏列表中的项目并显示内容
- java - 找到 findAny 匹配后如何停止并行流?
- javascript - Bootstrap 4标签:获取点击标签的索引号?