Binding click to a repeated div ID

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

    Use class instead of ID, repeating ID's isn't a good idea.

    Using classes you solve your problem: jsfiddle

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

提交回复
热议问题