这是包含字符的div,当我们点击执行j查询功能的字符并且显示其他国家时它是活动的
//这是我想在履行履带条件时保持活动的div。它包含国家的起始字符 p>
<div class="serving-nav">
<div class="container">
<span>COUNTRIES:</span>
<%-- <a href="javascript:void(0);" data-alpha="Popular Destinations" class="active">Popular Destinations</a>--%>
<a href="javascript:void(0);" data-alpha="A">A</a>// this character should be active when crawler condition is satisfied.
<a href="javascript:void(0);" data-alpha="B">B</a>
</div>
</div>
// whenever the crawler condition is Satisfied then it shows show the country of
//all the characters.
以下是展示热门国家/地区的div,默认为
<div class="serving-nav-data" style="display: block;" data-alpha="Popular Destinations">
<h5>Popular Destinations</h5>
<div class="serving-boxes">
<div class="row">
<% foreach (var p in popularRegionRates) {%>
<div class="col-sm-6">
<div class="serving-box">
<div class="the-flag">
<img src="/Content/images/AboutUs/country-flags/<%=p.CountryName %>.png" alt="<%=p.CountryName %> Courier" class="img-tall">
</div>
<% string modName="" ; //modName=p .CountryName.Replace( " AND ", " & "); modName=p .CountryName; if (modName.IndexOf( "(") !=- 1 && modName.Length>15) { modName = p.CountryName.Substring(0, p.CountryName.IndexOf('(')); %>
<h3 itemprop="offers" itemscope="" itemtype="" class="destiText" title="<%=%> Delivery from £<%=%>"><%=%> Delivery from <span itemprop="lowPrice">£<%=%></span></h3>
<%} else { if (modName.Length>18) {%>
<h3 itemprop="offers" itemscope="" itemtype="" class="destiText" title="<%=%> Delivery from £<%=p%>"><%=modName%> from <span itemprop="">£<%=p%></span></h3>
<%} else {%>
<h3 itemprop="offers" itemscope="" itemtype="" class="destiText" title="<%=%> Delivery from £<%=p%>"><%=%> Delivery from <span itemprop="">£<%=p%></span></h3>
<%} %>
<%}%>
<% if(string.IsNullOrEmpty(p.PageName)) {%>
<a class="book-btn trans-ease" title="to <%=p.CountryName %>" href="">Get Price & Book</a>
<%} else{ %>
<a class="book-btn trans-ease" title="to <%=p.CountryName %>" href="<%=p.PageName %>">Get Price & Book</a>
<%} %>
<div class="clearfix"></div>
</div>
</div>
<%} %>
</div>
</div>
</div>
以下是我想为抓取工具实施的条件
//Check userAgent to serve organic number to Googlebots
var gb = navigator.userAgent.toLowerCase().indexOf('googlebot');
//Check userAgent to serve organic number to Bingbots
var bb = navigator.userAgent.toLowerCase().indexOf('bingbot');
//Check userAgent to serve organic number to MSNbots
var mb = navigator.userAgent.toLowerCase().indexOf('msnbot');
//For Blocking Animation through QueryString
var qrStr = window.location.toString();
if (((gb > 0) || (bb > 0) || (mb > 0)) || (qrStr.indexOf('animation=false') > 0))
{
}
以上是必须实现的爬虫的条件,我不想在爬虫的情况下默认显示热门目的地div。它应该默认显示页面上的所有字符。
我在点击下面定义的字符时使用了j查询功能
jQuery(function ($) {
// Listen for Click
$(".serving-nav a").click(function (e) {
// Get the Character
var theChar = $(this).data('alpha');
// Hide Others
$(this).parent().find('a').not($(this)).removeClass('active');
$(".serving-data .serving-nav-data").stop(true, true).slideUp(500);
// $(".serving-data .serving-nav-data").show();
// Show the Related
$(this).addClass('active');
$(".serving-data .serving-nav-data[data-alpha='" + theChar + "']").stop(true, true).slideDown(500);
// Prevent Default
e.preventDefault();
return false;
});
// Trigger Click on Active One
$(".serving-nav a.active").click();
});
答案 0 :(得分:0)
你可以玩.show(); and .hide();
默认情况下.hide()divs然后如果condition为true .show()必要的div。