I have eight clickable icons (pulse1, pulse2 - pulse 8) which are linked to the corresponding content (content1, content2 etc). Instead of writing the code below out each time for each is there a way I can condense it down using an increasing integer or something? Fairly new to this game!
Dev version can be seen at http://aceresponsive.webdevspace.co.uk
Many thanks.
$("#pulse1").click(function () {
$(this).siblings(".active").removeClass("active");
$(this).toggleClass('active');
if ($('.purple-content').is(':visible')) {
if ($('#content1').is(':visible')) {
$(".purple-content").fadeOut();
} else {
$(".purple-content").fadeOut();
$("#content1").fadeToggle();
}
} else {
$("#content1").fadeToggle();
}
});
which calls for:
<div class="purple-content" id="content1">
<h2>the brain</h2>
<img src="assets/img/icons/brain-dark.png" width="144" height="167" alt="The Brain" class="alignright">
<p>Stroke … A serious medical condition that occurs when the blood supply to part of the brain is cut off. It can affect our bodily functions, thought processing, ability to learn, communication and emotions.</p>
<h3>Learn More</h3>
<ul>
<li><a href="#">The factors that can increase risk</a></li>
<li><a href="#">Stroke symptoms</a></li>
<li><a href="#">Types of stroke</a></li>
</ul>
</div>