I have this code
cuthtml += '<div style="background-image:url("'+response.images[ii].attachment_image_src+'"); background-position:center center; background-size:cover" class="cut-image6" data-id="'+data_id+'" image-id="'+image_id+'" post-author="'+post_author+'">';
but when it’s rendered, it comes up like this:
<div class="cut-image6" post-author="33073" image-id="162015" data-id="4" background-size:cover"="" center;="" background-position:center="" me_1352171624-200x200.jpg");="" bangstyle="" uploads="" wp-content="" www.bangstyle.com="" http:="" style="background-image:url(">
Not sure why I am getting negative votes…
The correct code should not be broken. I am wondering why it’s broken out like that. Do I need to escape something?
Looks like your problem is here:
After this gets rendered, your element will look something like this:
As you can see, the nested double-quotes will cause some problems. Instead, use escaped single-quotes: