我希望这个 jQuery 代码适用于许多地图,例如 for .map-1
, .map-2
, .map-3
.
HTML:
<div class="view-map" id="view-map">View Map</div>
<div class="map-1">
<div id="close" class="close-btn"></div>
</div>
<div class="view-map" id="view-map">View Map</div>
<div class="map-2">
<div id="close" class="close-btn"></div>
</div>
jQuery :
//when click on search toggle input
$("#view-map").click(function(){
$(".map" + $(this).parent().attr("class")).css( "display", "block" );
});
$("#close").click(function (event) {
$(".map" + $(this).parent().attr("class")).hide();
});