Rbex Rbex - 25 days ago 6
Javascript Question

Javascript object remove specific key

I'm having problem with this object array. I need to remove the object who match the removeVal.I't doesn't remove. See attached photos which is highlighted in red. I need to remove that all.

enter image description here

var removeVal = $(this).attr('href');
$.each(product_json, function(key, val){

if( key == removeVal) {
val.splice(key);
}

});


enter image description here

Answer

Hope this will helps you if i understand correctly,

var removeVal = $(this).attr('href'); 

delete product_json[removeVal]
Comments