My code like this :
<script>
var res = `
<a href="#" id="edit-image"
data-toggle="modal"
data-target="#modal-edit-image"
data-photo="`+JSON.stringify(photo)+`"
>
<span class="fa fa-pencil"></span>
</a>`;
</script>
The result of console.log(photo)
like this :
Object {id: 5, name: "IMziQFBIxFEFQHdjlg3mGXEVuQnwqZ5rYigX2jlq.jpeg", alt: "dea"}
I want to change it to json string and save it in variable res
I do it like above code, but if I inspect element and I copy the element the result like this :
<a href="#" id="edit-image" data-toggle="modal" data-target="#modal-edit-image" data-photo="{" id":5,"name":"imziqfbixfefqhdjlg3mgxevuqnwqz5ryigx2jlq.jpeg","alt":"dea"}"="">
<span class="fa fa-pencil"></span>
</a>
It seems json stringfy in the element untidy
How can I solve it?