2

I have several files (header.html, nav.html, footer.html). I was wondering if there's a way to include these files into index.html while the page loads (or before) using plain js or jquery library. I know it's better to do it from server-side, but right now I'm working on front-end and don't have access to server-side scripts.

When I try to use $.load('header.html'), it gives me the following error:

Uncaught TypeError: Object function (a,b){return new e.fn.init(a,b,h)} has no method 'load'

1 Answer 1

3

The load() function has to be called on a matched element.

$('#myDiv').load('test.html');

In this example, the content will be loaded to the myDiv element.

Sign up to request clarification or add additional context in comments.

1 Comment

yeah I just figured that out! THanks!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.