Issue
I am struggling to find a clean solution to my problem and was wondering if anyone could offer some tips.
I have "templates.html" which contains a collection of HTML snippets which I want to load into JavaScript and use. What is a good way to access the templates/snippets bearing in mind that templates.html is not a loaded DOM document?
I was thinking about using document.open
to create a DOM to access but I think this has issues on certain browsers.
Solution
You can load the html into a hidden div and then you will have a DOM access the easiest way to load the html to a DIV is using jquery load: http://api.jquery.com/load/
$( "#result" ).load( "ajax/test.html" );
Answered By - kleinohad
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.