Differences between jquery. load () and append

Source: Internet
Author: User

JQuery Event-Load () method

The load () event occurs when the specified element (and child element) is loaded.

Instance

When the image is loaded, change the text of the DIV element:
$ ("img"). Load (function () {
$ ("div"). Text ("Image Loaded");
});

Append () method

The Append () method inserts the specified content at the end of the selected element (still inside).

Tip: The Append () and Appendto () methods perform the same tasks. The difference is: the location of the content and the selector.

Instance

Insert content at the end of each P element:
$ ("button"). Click (function () {
$ ("P"). Append ("<b>hello world!</b>");
});

Application examples

More Articles

var url= '/ajaxarchive.php?page=1 ';

$ ("#archivePlaceHold"). Load (URL);

Jquery.load () can only replace the contents of the element.

Jquery.load () cannot use append at the same time, you need to use Jquery.get () to implement

var url= '/ajaxarchive.php?page=1 ';

$.get (URL, function (data) {
$ (data). Appendto ("#archivePlaceHold");
});

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.