When you click on a marker in your current code, $(this)
is referring to that specific marker. By using
$(this).removeClass('show').addClass('hide');
, you can hide the clicked marker.
If you assign a class
to your .infobox
elements that matches the id
of the clicked marker...
<div class="infobox hide termini">Bar<br>Termini</div>
...you can toggle them in this way...
$('.red-point').click(function() {
$('.infobox').removeClass('show').addClass('hide');
$('.' + $(this).attr('id')).addClass('show');
});
See this in action on JSFiddle
Personally, I prefer to give each marker a data attribute with the desired infowindow
text and use it to populate a single infowindow
...
<div class="infobox hide"></div>
<div class="abs red-point" id="termini" data-description="Bar<br>Termini">
<a onClick="turnGreen(event)">
<span class="num">1</span>
</a>
</div>
$('.red-point').click(function() {
$('.infobox').removeClass('hide').addClass('show').html($(this).data('description'));
});
Check out the JSFiddle Example here