user3522742
user3522742

Reputation: 51

Slashes got escaped in html append using js

This is the result of my DOM

<div style="background: #fff url(" http:="" i.imgur.com="" qeoj4ae.png")="" no-repeat="" center="" center;"="">

what I did is like this :

var htmlBlock = '<div id="bannerWrap"  style="background: #fff url("'+image+'") no-repeat center center;">';

why the slash got escaped? I console console.log(image), the slash is there.. I wonder..

Upvotes: 0

Views: 38

Answers (1)

Bhushan Kawadkar
Bhushan Kawadkar

Reputation: 28513

Try this : use \' to put images inside quotes.

var htmlBlock = '<div id="bannerWrap"  style="background: #fff url(\''+image+'\') no-repeat center center;">';

Upvotes: 1

Related Questions