Zephram
Zephram

Reputation: 499

Getting HTML from another file with JavaScript

I have several html pages and they all use a div that is exactly the same.

I want to have this same div in a separate file so that every time I have to make changes I won't have to copy the new version over and over again.

I don't know where to start and the proper terminology for this, but I'm confined to html and javascript.

Upvotes: 0

Views: 111

Answers (2)

spacebean
spacebean

Reputation: 1554

If you use jQuery you can use ajax.load as so:

$( "#yourDivId" ).load( "yourfile.html" );

http://api.jquery.com/load/

Upvotes: 1

Igl3
Igl3

Reputation: 5108

Search for Underscore Templates and how to use them.

Upvotes: 1

Related Questions