【发布时间】:2016-03-13 15:45:47
【问题描述】:
假设我的 html 如下:
<h3 class="search-result-title">
This is a test
<small class="search-result-subtitle">
Some more explanation
</small>
</h3>
如何在没有small 的情况下过滤文本This is a test?
编辑:我将它与 symfony Dom Crawler 一起使用。
所以我有filter(a. h3 search-result-title); 但我不想要small 元素的内容。
【问题讨论】:
-
这是一个 CSS 还是 jQuery 问题?
-
CSS 选择器只能选择元素(或伪元素)。不是文字。
-
或者你也可以使用 jquery .html() 函数。api.jquery.com/html
-
这是一个与 css 相关的问题。我在痛风爬虫中使用它。我根本不想要小元素及其内容
标签: jquery html domcrawler