Binding click to a repeated div ID

后端 未结 7 2025
孤独总比滥情好
孤独总比滥情好 2021-01-23 10:33

I\'m trying to create a div popup gallery type thing. But I\'m having an issue with my approach.

I have a few linked thumbnail images, which link to the lar

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-23 11:19

    An element's Id must be unique. So you can't have two a tags with same ids.

    
    
    
        

    JS:

    $('.galImage').click(function(e){
        e.preventDefault();
        alert($(this).attr("href"));
    });
    

提交回复
热议问题