This is the Html for my page I just want if there are no popular products then the whole div popular_prd should hide.
<div class="popular_prd">
<h1 class="views-heading">Popular Products</h1>
<div class="view view-popular-products view-id-popular_products view-display-id-default boxes-bottom view-dom-id-3">
<div class="views-admin-links views-hide">
<ul class="links">
<li class="0 first">
<a href="/admin/build/views/edit/popular_products?destination=node#views-tab-default">Edit</a>
</li>
<li class="1">
<a href="/admin/build/views/export/popular_products">Export</a>
</li>
<li class="2 last">
<a href="/admin/build/views/clone/popular_products">Clone</a>
</li>
</ul>
</div>
</div>
</div>
I used the following jquery code to hide tthe div.
$('document').ready(function(){
if(!$('.popular_prd').find('.view-content') ) {
$('.popular_prd').hide();
}
else {
$('.popular_prd').show();
}
});
But the code is not working the div is still showing up.
finddoesn’t work the way you think. It looks like instead ofwhat you mean is
In fact, you don’t even need
findhere…Bottom line, jQuery selectors don’t return true or false, but a set. Test the
lengthto see whether anything was found.