I want to hide p element
and show it when second tabpanel is active. I have a panel in bootstrap like this:
<div id="Mobile-menu">
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12"><h2>Do You have a smartphone ?</h2></div>
</div>
<div class="row">
<div class="col-lg-12">
<div id="mobile-panel" role="tabpanel">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" id="smartphone-on" class="active"><a href="#smart-yes" aria-controls="home" role="tab" data-toggle="tab">Yes</a></li>
<li role="presentation" id="smartphone-off" ><a href="#smart-no" aria-controls="profile" role="tab" data-toggle="tab">No</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="smart-yes">
<div class="smart-item 1">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
<div class="smart-item 2">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
<div class="smart-item 3">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
<div class="smart-item 4">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
</div>
<div role="tabpanel" class="tab-pane" id="smart-no">
<div class="smart-item 1">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
<div class="smart-item 2">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
<div class="smart-item 3">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
<div class="smart-item 4">
<h2>Lorem ipsum</h2>
<p>sit dolor amet</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<p id="menu-legend">*not available</p>
</div>
</div>
</div>
</div>
I added to footer.php javascript code, because I want to show paragraph with id="menu-legend"
,when panel second is active (li#smartphone-off)
, but it's not working. jQuery library is loading - when i added below only $("#menu-legend").hide();
-it's working good. Where's the problem ?
<?php
}
if ($pagename == "New smartphones - Landin Page"){
?>
<script type="text/javascript">
$("#menu-legend").hide();
if ($("smartphone-off").hasClass("active")){
$("#menu-legend").show();
};
</script>
<?php
}
?>
Try this code:
$(function(){ //put your code inside document ready
$("#menu-legend").hide();
if ($("#smartphone-off").hasClass("active")){ //add # to smartphone-off selector
$("#menu-legend").show();
};
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.