Reputation: 249
I am having trouble calling the right div
to hide.
Underneath is my code and I would like to hide li#spect1
if #block1
is empty.
If I call, for example, the above div #tab1
it will hide, but #block1
will not.
Can anybody help me please?
<script type="text/javascript">
$j(function() {
if ($j("div#block1").html() == "") {
$j("li#spect1").hide();}
});
</script>
<div class="content_container">
<ul class="tabs">
<li id="spect1"><a href="#tab1">Title of tab</a></li>
</ul>
<div class="tab_container">
<div id="tab1">
<div id="block1"></div><!--if div is empy = hide-->
</div>
</div><!--end tab_container-->
</div><!--end content_container-->
EDIT
$J
is for calling jQuery or simple $
on the Magento platform.
When div#block1
is empty , hide li
element #spect1
.
It works when I put #tab1
instead of #block1
is empty, but I am searching a way to call div#block1
. This won't work and I dont know why.
Upvotes: 1
Views: 514
Reputation: 2654
Hide the tab1 div too :
<script type="text/javascript">
$j(function() {
if ($j("div#block1").html() == "") {
$j("li#spect1").hide();
$j("#tab1").hide();
}
});
</script>
Upvotes: 1
Reputation: 5128
You need to hide the actual block as well:
<script type="text/javascript">
$j(function() {
if ($j("div#block1").html() == "") {
$j("div#block1").hide();
$j("li#spect1").hide();
}
});
</script>
Upvotes: 2