Reputation: 3039
I wrote a code to create a bootstrap panel and add some elements and remove them when clicked on Remove
icon. When I click on Remove
icon, background of all elements will be removed. I don't want this to happen. I want background of particular element whose Remove
icon is clicked to be removed. My Code:
$(document).ready(function (){
$(".remove_gly").click(function () {
//alert('Clicked');
//var catName = $(span).closest('a').text();
// var index = subscriptionArrays.indexOf(catName);
// if (index > -1) {
//subscriptionArrays.splice(index, 1);
// }
//span.parentNode.innerHTML = span.innerHTML;
$("a").closest(".droggIng").removeClass("droggIng");
});
});
JSFiddle link: https://jsfiddle.net/kqcs0pq9/8/
How can I do it?
Upvotes: 1
Views: 84
Reputation: 179
Please try this code, it will do the job-
$(document).ready(function (){
$(".remove_gly").click(function () {
$(this).parent(".droggIng").removeClass("droggIng");
});
});
Upvotes: 0
Reputation: 3294
Remove a
and add this
$(this).closest(".droggIng").removeClass("droggIng");
Upvotes: 2