0

Suppose that you can retrieve an HTML page through a call by using the jQuery.get() function, e.g. as follows:

$.get('xxx.php', 
        function(data) {
        //handle data, that is HTML code....
});

Is there any jQuery solution to extract elements (e.g. div, ul and so on) by the data variable?

PS: I don't believe that using load() to load page fragments is a good idea since I want to minimize the number of server requests.

JeanValjean
  • 17,172
  • 23
  • 113
  • 157

1 Answers1

2
$.get('xxx.php', 
        function(data) {
        //handle data, that is HTML code....
        var pageDivs = $(data).find('div');
});

Just make the HTML returned a jquery object and you can use any DOM functions normally.

idrumgood
  • 4,904
  • 19
  • 29