1 回答
TA贡献1811条经验 获得超5个赞
你可以这样做:
$(document).ready(function() {
$(".region").each(function() {
if ($(this).text() != "Texas") {
$(this).closest(".m-s-a").remove();
}
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="row m-s-a _hidden">
<table>
<tr>
<td class="for-sale-heading">
<h4>Auction: </h4>
</td>
<td class="for-sale-heading">
<h4>Hard rock Cafe</h4>
</td>
</tr>
<tr>
<td class="for-sale-heading">
<h4>Location: </h4>
</td>
<td class="for-sale-heading">
<h4>4641 Production unit 42 Mt. Clemens, <span class="region">Michigan</span> 48043</h4>
</td>
</tr>
</table>
</div>
<div class="row m-s-a _hidden">
<table>
<tr>
<td class="for-sale-heading">
<h4>Auction: </h4>
</td>
<td class="for-sale-heading">
<h4>Hard rock Cafe</h4>
</td>
</tr>
<tr>
<td class="for-sale-heading">
<h4>Location: </h4>
</td>
<td class="for-sale-heading">
<h4>4641 Production unit 42 Mt. Clemens, <span class="region">Utah</span> 48043</h4>
</td>
</tr>
</table>
</div>
<div class="row m-s-a _hidden">
<table>
<tr>
<td class="for-sale-heading">
<h4>Auction: </h4>
</td>
<td class="for-sale-heading">
<h4>Hard rock Cafe</h4>
</td>
</tr>
<tr>
<td class="for-sale-heading">
<h4>Location: </h4>
</td>
<td class="for-sale-heading">
<h4>4641 Production unit 42 Mt. Clemens, <span class="region">Texas</span> 48043</h4>
</td>
</tr>
</table>
</div>
这必须根据您的需要进行调整,例如,与其将 的文本与<span class="region">
“Texas”进行比较,不如将其与data.location.region
您<pre>
在示例中添加此区域的位置进行比较 - $("pre").text()
,以防它是<pre>
您页面上唯一的。
添加回答
举报