Hi,
I have a page that is supposed to display a larger version of an image when hovered over a thumbnail.
I have a 'div' with an ID and the JQuery code is as following:
$(document).ready(function(){
$('img').hover(function() {
var src = $("#im" + this.id).attr("src");
$('#viewlarge').css('backgroundImage','url(' + src +')');
return false;
});
});
The images I use, are generated by a Ruby script that "generate" an image with a similar, yet different id. However, sometimes, photo's are uploaded that have "spaces" inside. My developer tools tell me that the background-image is not set correctly, yet the image path is correct and the browser don't have problems finding the image.
My question is, can I somehow sanitize the url 'src', so spaces won't be a problem? I am aware of doing this server side, yet I would like to know how to do this with JQuery/JS too.
Thanks!