javascript - How to add this html in a div, escaping the quotes? -
javascript - How to add this html in a div, escaping the quotes? -
i have html code want add together dynamically div in page.
my div is:
<div id="my_div" class="my_class"> </div>
this html code want add together above div, when click on button, using jquery onclick event.
<div id="content"> 'hello world 123' <br> <img src='player.gif' width='200' height='100'> morning... have nice day... </div>
so far, tried general way, when onclick event invoked:
document.getelementbyid("my_div").innerhtml = '<div id="content"> 'hello world 123' <br> <img src='player.gif' width='200' height='100'> morning... have nice day... </div>';
but can see, code error prone, quotes mismatched , breaks. how can escape quotes , add together content div efficiently?
this should job:
document.getelementbyid("my_div").innerhtml = "<div id=\"content\"> 'hello world 123' <br> <img src='player.gif' width='200' height='100'> morning... have nice day... </div>";
instead have escaped double quotes around content.
javascript jquery html
Comments
Post a Comment