Extract part of HTML document in jQuery

前端 未结 5 1616
囚心锁ツ
囚心锁ツ 2020-11-28 09:01

I want to make an AJAX call to an HTML-returning page, extract part of the HTML (using jQuery selectors), and then use that part in my jQuery-based JavaScript.

The A

5条回答
  •  無奈伤痛
    2020-11-28 09:59

    You can do the thing this way

    $.get(
            url,
            {
              data : data
            },
            function (response) {
                var page_content = $('.page-content',response).get(0);
                console.log(page_content);
            }
        )
    

    Here in the console.log you will see the inner HTML of the expected/desired portion from the response. Then you can use it as your wish

提交回复
热议问题