jQuery Methods: load()

By: Dusty Arlia
Published on Tuesday, December 10, 2013, 06:29 AM
Last Updated on Saturday, July 11, 2015 at 9:07 PM
Total Updates: 2

The load() jQuery method is used to asynchronously load the contents of a URL into the contents of a jQuery object. You can also load specific elements of a URL. Here is the basic syntax:

$('#title').load('article_to_be_loaded.html #article_title');

In the example above, article_to_be_loaded.html #article_title is the id="article_title" element on the article_to_be_loaded.html. The contents of this element replaces the contents of the #title jQuery object.

Also, If the first argument to the load() method is a function, then load() is used as an event handler instead of as an Ajax method.