how export html code in js file for use it jquery script? -
i have html code:
<html> <head> ... // call jquery etc // <script src="dialog.js"></script> ... <script type="text/javascript"> openmydialog(); // open dialog defined jquery in dialog.js // </script> </head> <body> ... <div id="my-div"> text </div> ... </body> </html>
well, work correctly. have problem. how can export the:
<div id="my-div"> text </div>
in dialog.js , work correctly? have tried defining variable, writing like:
var myvar = '<div id="my-div"> text </div>'; $("#my-div").html(myvar);
but did not worked. have tried document.write
same. solution it?
you close, if you're starting html...
var myvar = '<div id="my-div"> text </div>';
...you need parse , add page somewhere
$(myvar).appendto(document.body); // ^^^^^^^^ ^^^^^^^^ ^^^^^^^^^^^^^ // parse add somewhere
appendto
1 of many ways can add page; more on (and jquery in general, including how parse snippets of html) in documentation.
Comments
Post a Comment