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

Popular posts from this blog

java - How to pass parameters between Request-Scoped Controllers? -

actionscript 3 - Flex: moving a point with rotation doesnt change the point XY? -

string - what is the difference between "some" == "some\0" and strcmp("some","some\0") in c++? -