I am trying to save the background image of an element, delete it, and then maybe add it later.
var current_bg_image = $("#div").css("background-image");
if(something){
$("#div").css("background-image", "none");
}else{
$("#div").css("background-image", current_bg_image);
}
The part that the background image is supposed to be added to does not work ... But if I changed current_bg_imageto "url(something.jpg)", it will work. Does css () seem to not work with variables?
source
share