【发布时间】:2016-12-05 15:09:57
【问题描述】:
我在搜索结果页面上有一个动态的属性列表,我在每个单独的搜索结果中遇到的问题是,如果它是某种属性类型,即土地,它不需要该搜索结果中的卧室和浴室字段显示,但如果是别墅,字段会显示。
我需要在 JS 中的页面加载上显示和隐藏字段,就像我上面在每个单独的搜索结果中的示例一样,就像我为 Land 执行通用 JS 函数一样,隐藏卧室和浴室的 div 类,也可能有一个需要这些字段的页面上的别墅。
如果有人可以提供一些 JS 来帮助我解决上述问题,将不胜感激!
下面是一些 Html 结果,你会看到有多种属性类型,所以应该显示/隐藏不同的字段
<div class="property-listing">
<ul>
<li class="col-md-12">
<div class="col-md-4">
<a href="/propertydetails.aspx?SalePropertyID=615237" class="property-featured-image"><div class="overlay" style="line-height:167px"><i class="fa fa-search"></i></div>
<img src="http://example.com/ImageProcessor.aspx?watermarkImageFileName=&Text=NEW LISTING&imageURL=487/Sales/615237/615237_7969.jpg" alt="Villa in Javea">
<span class="images-count">
<i class="fa fa-link"></i>
MidasS
</span>
</a>
</div>
<div class="col-md-8">
<div class="property-info">
<div class="price"><span>115.000</span><strong>€</strong></div>
<div class="title">
<a href="/propertydetails.aspx?SalePropertyID=615237" title="Villa in Javea">
Villa in Javea
</a>
</div>
<span class="location"><i class="fa fa-map-marker"></i> Alicante, SPAIN</span>
<p>A beautiful and rustic style 'home' offering spectacular views over the coast, the mountains and the Mediterranean Sea.</p>
</div>
<div class="property-amenities clearfix">
<span id="spbeds"><strong>2</strong>Bedrooms</span>
<span id="spbaths"><strong>1</strong>Bathrooms</span>
<span id="sppool"><strong>Yes</strong>Pool</span>
</div>
</div>
</li>
<li class="col-md-12">
<div class="col-md-4">
<a href="/propertydetails.aspx?SalePropertyID=638700" class="property-featured-image"><div class="overlay" style="line-height:167px"><i class="fa fa-search"></i></div>
<img src="http://example.com/ImageProcessor.aspx?watermarkImageFileName=&Text=REDUCED&imageURL=487/Sales/638700/638700_1145.jpg" alt="Apartment in Famagusta">
<span class="images-count">
<i class="fa fa-link"></i>
PRO1011
</span>
</a>
</div>
<div class="col-md-8">
<div class="property-info">
<div class="price"><span>155.000</span><strong>€</strong></div>
<div class="title">
<a href="/propertydetails.aspx?SalePropertyID=638700" title="Apartment in Famagusta">
Apartment in Famagusta
</a>
</div>
<span class="location"><i class="fa fa-map-marker"></i> Famagusta, CYPRUS</span>
<p>hnglkrehnblarjl;kbkhmtr;mnb;rstlmnstrn</p>
</div>
<div class="property-amenities clearfix">
<span id="spbeds"><strong>0</strong>Bedrooms</span>
<span id="spbaths"><strong>0</strong>Bathrooms</span>
<span id="sppool"><strong>No</strong>Pool</span>
</div>
</div>
</li>
<li class="col-md-12">
<div class="col-md-4">
<a href="/propertydetails.aspx?SalePropertyID=636364" class="property-featured-image"><div class="overlay" style="line-height:188px"><i class="fa fa-search"></i></div>
<img src="http://example.com/487/Sales/636364/636364_5562.jpg" alt="Country House in Not Specified">
<span class="images-count">
<i class="fa fa-link"></i>
cyc130
</span>
</a>
</div>
<div class="col-md-8">
<div class="property-info">
<div class="price"><span>175.000</span><strong>€</strong></div>
<div class="title">
<a href="/propertydetails.aspx?SalePropertyID=636364" title="Country House in Not Specified">
Country House in Not Specified
</a>
</div>
<span class="location"><i class="fa fa-map-marker"></i> Andalucia, SPAIN</span>
<p>;.lkijuhygtfrdeswaq</p>
</div>
<div class="property-amenities clearfix">
<span id="spbeds"><strong>3</strong>Bedrooms</span>
<span id="spbaths"><strong>1</strong>Bathrooms</span>
<span id="sppool"><strong>Yes</strong>Pool</span>
</div>
</div>
</li>
<br> <br>
<div class="pagination">
<span class="disabled"><i class="fa fa-chevron-left"></i></span>
<a href="/searchresults.aspx?SearchID=94829-544&Page=1" class="page, active">1</a>
<a href="/searchresults.aspx?SearchID=94829-544&Page=2" class="page">2</a>
<a href="/searchresults.aspx?SearchID=94829-544&Page=3" class="page">3</a>
<a href="/searchresults.aspx?SearchID=94829-544&Page=4" class="page">4</a>
<a href="/searchresults.aspx?SearchID=94829-544&Page=2" class="next"><i class="fa fa-chevron-right"></i></a>
</div>
</ul>
</div>
【问题讨论】:
-
您需要向我们展示一些代码,至少您的 HTML 和数据是如何结构化的,最好是您目前拥有的 javascript。
-
请阅读帮助中心,特别是 How do I ask a good question? 和 How to create a Minimal, Complete, and Verifiable Example。任何人都无法帮助您提供所提供的信息,我们需要知道您为尝试解决您的问题所做的工作。
-
请展示一些代码和您尝试过的内容
标签: javascript jquery html css