javascript - jQuery append adding extra qoute -
my code:
$("#thescreenshots").append("<img class='screenshotthumbnails' onclick='openscreenshotmodal('"+datareturned['screenshots'][i]+"')' src='/assets/screenshots/"+ datareturned['screenshots'][i] +"'>");
is outputting:
<img class="screenshotthumbnails" onclick="openscreenshotmodal(" 'img_0203.png')'="" src="/assets/screenshots/img_0203.png">
why add weird qoute? , how can fix this?
you need escape of quotes. try this:
$("#thescreenshots").append('<img class="screenshotthumbnails" onclick="openscreenshotmodal(\''+datareturned['screenshots'][i]+'\')" src="/assets/screenshots/'+ datareturned['screenshots'][i] +'">');
it output this:
<img class="screenshotthumbnails" onclick="openscreenshotmodal('img_0203.png')" src="/assets/screenshots/img_0203.png">
Comments
Post a Comment