Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

alya_alsiyabi's avatar

a href is not working

Hi I have an interactive map. as shown in the photo:

https://i.stack.imgur.com/uf7Kk.png

When I hover any place, it gives me information about that place, by the use of JavaScript code below i used this class for doing so: cd-popup-trigger I want to make all these icon clickables by the use of "a href=" but href is not working because of the script, i use the following code in the view:

<!-- Hiking -->
             <div class="map1 targetDiv cd-popup-trigger" id="div1" style="display:block;">
                <div class="map-div">
                    <img src="frontend/assets/images/map1.png" alt="" class="img-fluid map-img">
                     <img src="frontend/assets/images/map1.png" class="img-fluid icon icon10 cd-popup-trigger" data-id="Pop_Ministry_10"  />
                     <!-- these are the icons -->
                    <a href="/"><!--I applied the href here-->
                    <img src="frontend/assets/images/hikingicon.png" class="img-fluid icon icon10 cd-popup-trigger" data-id="Pop_hiking_8"/>
                     </a>
                    <a href="/"><img src="frontend/assets/images/hikingicon.png" class="img-fluid icon icon9 cd-popup-trigger" data-id="Pop_hiking_9" /></a>
                    <a href ="/"><img src="frontend/assets/images/hikingicon.png" class="img-fluid icon icon6 cd-popup-trigger" data-id="Pop_hiking_10" /></a>
                </div>
            </div>

I used this JavaScript > that is why href is not clickable:

<script>


        // filter click event
        $(".mapFilter-item").on("click", function () {
            var _this = $(this);
            ActiveTab = _this.attr("data-type");

            $(".mapFilter-item").removeClass("is-mapFilterActive");
            _this.addClass("is-mapFilterActive");

        });

//for filter

        jQuery(function () {
            jQuery('.showSingle').click(function () {
                jQuery('.targetDiv').hide();
                jQuery('#div' + $(this).attr('target')).show();
            });
        });




//for alart
jQuery(document).ready(function($){
        //open popup
    $('.icon.cd-popup-trigger').mouseenter(function () {

                $('.cd-popup').removeClass('is-visible');
                divId = $(this).attr('data-id');
                event.preventDefault();
                $('#' + divId).addClass('is-visible');
            //event.preventDefault();
            //$('.cd-popup').addClass('is-visible');
    });


    $('.icon.cd-popup-trigger').click(function () {

        $('.cd-popup').removeClass('is-visible');
        divId = $(this).attr('data-id');
        event.preventDefault();
        $('#' + divId).addClass('is-visible');
        //event.preventDefault();
        //$('.cd-popup').addClass('is-visible');
    });

        //close popup
        $('.cd-popup').on('click', function(event){
            if( $(event.target).is('.cd-popup-close') || $(event.target).is('.cd-popup') ) {
                    event.preventDefault();
                    $(this).removeClass('is-visible');
            }
        });
        //close popup when clicking the esc keyboard button
    $(document).keyup(function (event) {

        if(event.which=='27'){
            $('.cd-popup').removeClass('is-visible');
            }
    });

});

Is there any way to let a href works and when hover it the script works




    </script>
0 likes
6 replies
alya_alsiyabi's avatar

@Sinnbeck it should be home page. when I write any title beside the icon or even this a href it goes under the map by dimention of 0× 17.33. Is position: relative effect it (the href)? becasue i apply some syles in the div map

<!-- Hiking -->
             <div class="map1 targetDiv cd-popup-trigger" id="div1" style="display:block;">
 <!-- here whr i pplied relative position-->
<!-- map-->

                <div class="map-div">
                    <img src="frontend/assets/images/map1.png" alt="" class="img-fluid map-img">
                     <img src="frontend/assets/images/map1.png" class="img-fluid icon icon10 cd-popup-trigger" data-id="Pop_10"  />
                     <!-- these are the icons -->
                    <a href="/"> <!--I applied the href here-->
                    <img src="frontend/assets/images/hikingicon.png" class="img-fluid icon icon10 cd-popup-trigger" data-id="Pop_hiking_8"/>
                     </a>
                    <a href="/"><img src="frontend/assets/images/hikingicon.png" class="img-fluid icon icon9 cd-popup-trigger" data-id="Pop_hiking_9" /></a>
                    <a href ="/"><img src="frontend/assets/images/hikingicon.png" class="img-fluid icon icon6 cd-popup-trigger" data-id="Pop_hiking_10" /></a>
                </div>
            </div>

icons these is there style and map div and icons

.map1 .map-div {position: relative;}
.map1 .map-div .icon{width: 25px; height: 25px; position: absolute; cursor:pointer;}

I tried to give href some height or top, but it is not affecting

Snapey's avatar

since you move the icon it's not clickable, either move the anchor (with the icon in it) or remove all the anchors and add an onclick handler to the icon

alya_alsiyabi's avatar

@Snapey sir i think this is because of JavaScript i just realized that when I remove the class responsible for that the a href is working . But i need that class to show the alert. Is there a way to let both of them works

Please or to participate in this conversation.