我想在找到“电池”字符串之后找到下一句。文本没有标签,只有引号。
<html>
<h2 class="inshallah">film</h2>
<h2 class="inshallah">battery</h2> << using this string "battery"
"coucou test tt test" << text to find
<h2 class="inshallah">dress</h2>
</html>
我试过了,但是如果之后没有标签,它就不起作用
var test = $('.inshallah').filter(function() {
return $(this).text().trim() === "battery";
}).next().text();
console.log(test)