Ajay Kulkarni
Ajay Kulkarni

Reputation: 3039

removing background of specific anchor tag

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

Answers (3)

Rahul Mishra
Rahul Mishra

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

NID
NID

Reputation: 3294

Remove a and add this

$(this).closest(".droggIng").removeClass("droggIng"); 

Upvotes: 2

4b0
4b0

Reputation: 22323

use this :

$(this).closest(".droggIng").removeClass("droggIng"); 

Updated Fiddle

Upvotes: 0

Related Questions