I currently have a script that toggles the visibility of a div when selected:
$('.showSingle').click(function () {
$('.targetDiv').hide();
$('.showSingle').removeClass('greenactive');
$(this).addClass("greenactive")
$('#div' + $(this).attr('target')).show();
});
.greenactive {
background-color: green; border-radius: 25px; padding: 10px; color: #fff; font-size: 14px; color: #;
}
.showSingle {
background-color: #ffffff border-radius: 25px; padding: 10px; color: #; font-size: 14px; color: #;
}
.showSingle:hover {
background-color: #e4e6e8; border-radius: 25px; padding: 10px; color: #535a60; font-size: 14px; color: #;
}
<a href="#"><div style="display: inline-block;" class="showSingle" target="01">Selection1</div></a>
<a href="#"><div style="display: inline-block;" class="showSingle" target="02">Selection2</div></a>
<a href="#"><div style="display: inline-block;" class="showSingle" target="03">Selection3</div></a>
<div id="div01" class="targetDiv" style="display:none">
Target01 Content
</div>
<div id="div02" class="targetDiv" style="display:none">
Target02 Content
</div>
<div id="div03" class="targetDiv" style="display:none">
Target03 Content
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
Currently, no div is shown by default.
The divs are only displayed upon clicking on one of the links.
How can I set it so that div01 is automatically selected and shown with my CSS styles applied?
Any assistance would be greatly appreciated.