After getting a page's content from an AJAX request I can select tag element but cannot select body element

后端 未结 3 1329
不思量自难忘°
不思量自难忘° 2021-01-26 16:27

I got an html page through an AJAX request

$.ajax({
    async: true,
    method: \'GET\',
    url: linkPage,
    // cache: true,
    success: function (data) {
          


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-26 17:21

    The following jQuery Won't work:

    $(data).find('sustainable');
    

    as the divs are top level elements and data isn't an element but a string, to make it work you need to use .filter

    $(data).filter('sustainable.wrap');
    

提交回复
热议问题