Fernandez
Fernandez

Reputation: 61

concatenation string with links missing slashes

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

Answers (1)

Satpal
Satpal

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

Related Questions