Reputation: 61
console.log(mylink)
with above console, mylink
result is like normal, like http://example.com/something.jpg.
I concatenated it like this
var html = '<div id="head" style="background:linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),url("'+ mylink+'") no-repeat;">';
but the result is broken, in my DOM I see the slashes is gone.
Upvotes: 0
Views: 87
Reputation: 133403
Escape quotes like\'
Use
var html = '<div id="head" style="background:linear-gradient(rgba(0, 0, 0, 0.35), rgba(0, 0, 0, 0.35)),url(\'"'+ mylink+'\') no-repeat;">';
Upvotes: 2