Search code examples
javascriptjqueryuserscripts

jquery - Get contents of other page


This is my function:

        $.get(profileAddress, function(data){
            alert(data);
        })

The alert displays sourcecode of page profileAddress.

How can I get for example first div from that "data"?

I need to get specific div from that profileAddress page and display it on my page.

I know how to do second part. I only need help on how to get div from that data that is passed to that function.


Solution

  • Something along the lines of this will give you the div you're interested in:

    var selectedDiv = $(data).find('selector_for_div');
    

    Then you could append it after one (or more) elements like so:

    $('selector_for_element_to_append_after').append(selectedDiv);