Juri Juri - 8 months ago 51
jQuery Question

Traversing the DOM with load() method

In jQuery, the

method allows you to import the specific content, for example, of a certain
using selectors:

$("#div1").load("demo_test.txt #p1");

With jQuery (and if possible without functions but just using selectors), how do I select, for example, the previous element to that

Eg 1 (mistaken):

$("#div1").load("demo_test.txt #p1").prev();

Eg 2 (mistaken):

$("#div1").load("demo_test.txt #p1.prev()");

Answer Source

You can't do that with load() method instead of that use jQuery.get and get the element from the response.