In my page I have multiple instances of the .close class on various objects.
I am trying to use the jQuery each function to look for all of them, then depending on which is actually clicked, calling an alert.
Here is a snippet of my code:
$(".close").each(function(){
var removetab = $(this).parent().parent().attr("id");
var tabid = removetab.split("-")[1];
$("#tab-" + tabid + " .close").click(function() {
alert($(this).siblings().text());
});
});
This issue is, if there are 4 instances of the .close class on the page, when the first instance is clicked, the alert fires 4 times, the second instance, it fires 3 times, and so on.
How can I have this just pull each of the .close functions and look for a click on the independent section?
Thanks.