Friday, May 10, 2024
 Popular · Latest · Hot · Upcoming
19
rated 0 times [  26] [ 7]  / answers: 1 / hits: 90878  / 13 Years ago, thu, june 23, 2011, 12:00:00

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.


More From » html

 Answers
87

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 );

[#91554] Tuesday, June 21, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
darleneh

Total Points: 231
Total Questions: 110
Total Answers: 94

Location: Spain
Member since Thu, Dec 23, 2021
2 Years ago
;