Reputation: 415
I'm having troubles with the syntax for a simple line of jquery, I cant seem to insert the 'this.src' part correctly, I get muddled up with quotes and commas etc. Heres what I currently have :
$('#blog-hover-image').css("background-image", "url(", this.src, ")");
How do I insert the this.src part correctly please ?
I have a url stored in this.src from earlier in the file.
Thank you.
Upvotes: 0
Views: 28
Reputation: 1074
You were close but you need to use the +
for string concatenation, not the ,
.
$('#blog-hover-image').css("background-image", "url('" + this.src + "')");
Upvotes: 1
Reputation: 208002
Like this
$('#blog-hover-image').css("background-image", "url(\"" + this.src + "\")");
Upvotes: 3