Binding click to a repeated div ID

后端 未结 7 2115
孤独总比滥情好
孤独总比滥情好 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:24

    You need to use classes instead as IDs must be unique.

    E.g

    
       
    
    

    and your jQuery would be

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

提交回复
热议问题