Extract part of HTML document in jQuery

前端 未结 5 1631
囚心锁ツ
囚心锁ツ 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:52

    You can use load on a new element, and pass that to a function:

    function handle(element){
      $(element).appendTo('body');
    }
    
    $(function(){
      var div = $('
    '); div.load('/help a', function(){handle(div);}); });

    Example: http://jsbin.com/ubeyu/2

提交回复
热议问题