Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to import HTML using JavaScript?

I have some html pages with the same footer. With JavaScript and only JavaScript could I import another html page inside it?

like image 290
ulima69 Avatar asked Jan 27 '11 16:01

ulima69


1 Answers

As above, one method is to use jQuery load. I happened to be doing the exact same thing now, so will post a quick example.

Using jQuery:

$("#yourDiv").load('readHtmlFromHere.html #readMe');

And your readHtmlFromHere.html page would consist of:

<div><div id="readMe"><p>I'm some text</p></div></div>
like image 155
Ricky Avatar answered Oct 10 '22 10:10

Ricky