Search code examples
javascriptjqueryhtmlcssjquery-load

Use jQuery on Elements from .load()


Is it possible to use jQuery on elements inserted into the page using:

jQuery('#here').load('slick.txt');

I want to use jQuery on one of the elements in slick.txt but it doesn't work:

jQuery('p').hide();

Solution

  • Use a Load complete callback to .load()

    A callback function that is executed when the request completes.

    jQuery('#here').load('slick.txt', function() {
        jQuery('p').hide();
    });