How to get the html of a div on another page with jQuery ajax?

前端 未结 5 1111
忘掉有多难
忘掉有多难 2020-11-27 12:30

I\'m using jQuery\'s ajax code to load new pages, but wanted him to get only the html of a div.

My codes: HTML:


    
5条回答
  •  借酒劲吻你
    2020-11-27 13:09

    Ok, You should "construct" the html and find the .content div.

    like this:

    $.ajax({
       url:href,
       type:'GET',
       success: function(data){
           $('#content').html($(data).find('#content').html());
       }
    });
    

    Simple!

提交回复
热议问题