简体   繁体   中英

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?

取出a ,并添加this

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

use this :

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

Updated Fiddle

Please try this code, it will do the job-

$(document).ready(function (){
    $(".remove_gly").click(function () {

        $(this).parent(".droggIng").removeClass("droggIng"); 
    });
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM