I am changing background:url('image-file') or img's src dynamically and it’s doing as i expected but one problem i am getting when the file has space between the name e.g. file name.gif (Not loading) or file-name.gif (load successfully)
var file-src = ../context/image file.jpg /*not changing */
/* ../context/image-file.jpg : changes */
if(this.is('img')){ /* 'this' is selecter */
this.attr('src', file_src);
}else{
this.css('background','url('+ file_src +')');
}
as far as i am not very sure why such files are not loading, i just try my best to find out the reason but i want to know if there could be any other reason.
You should cover filename by quote. Your code should be change to: