I would like this Show/hide script to show the first hidden text on startup and at all times only show max one hidden content. So if im displaying the hidden content of text 3 and before i was viewing the hidden content of text 1 i know want the text 1 to slide back up if i press text 3, all in same .slidetoggle i have now.
$(document).ready(function() {
$(".neverseen img").click(function() {
$(this).parent().toggleClass("active");
$(".neverseen p").slideToggle("slow");
return false;
});
});
$(document).ready(function() {
$(".neverseen1 img").click(function() {
$(this).parent().toggleClass("active");
$(".neverseen1 p").slideToggle("slow");
return false;
});
});
$(document).ready(function() {
$(".neverseen2 img").click(function() {
$(this).parent().toggleClass("active");
$(".neverseen2 p").slideToggle("slow");
return false;
});
});
$(document).ready(function() {
$(".neverseen3 img").click(function() {
$(this).parent().toggleClass("active");
$(".neverseen3 p").slideToggle("slow");
return false;
});
});
#leftpanel h1 {font-size: 18px; font-family: 'Montserrat bold'; color:#b0a887; border-top: 1px solid #b0a887; font-style: normal;}
#leftpanel p {display: none; color: #333; font-size: 14px;}
#leftpanel a {margin-left: 230px;}
#leftpanel img {}
.secondImage{
display: none;
}
.active .firstImg{
display:none;
}
.active .secondImage {
display: inline-block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="leftpanel">
<div class="neverseen">
<h1>First title</h1>
<a href="#" id="show">
<img class="secondImage" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-down-01-128.png" width="40" height="40">
<img class="firstImg" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-up-01-128.png" width="40" height="40">
</a>
<p>First text</p>
</div>
<div class="neverseen1">
<h1>Second title</h1>
<a href="#" id="show1">
<img class="secondImage" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-down-01-128.png" width="40" height="40">
<img class="firstImg" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-up-01-128.png" width="40" height="40">
</a>
<p>Second text</p>
</div>
<div class="neverseen2">
<h1>Third title</h1>
<a href="#" id="show2">
<img class="secondImage" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-down-01-128.png" width="40" height="40">
<img class="firstImg" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-up-01-128.png" width="40" height="40">
</a>
<p>Third text</p>
</div>
<div class="neverseen3">
<h1>Last title</h1>
<a href="#" id="show3">
<img class="secondImage" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-down-01-128.png" width="40" height="40">
<img class="firstImg" src="https://cdn3.iconfinder.com/data/icons/faticons/32/arrow-up-01-128.png" width="40" height="40">
</a>
<p>Last text</p>
</div>
</div>
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…