Get innerhtml from external page with Javascript

前端 未结 6 568
离开以前
离开以前 2021-02-04 17:47

I\'m trying to get innerHTML of a DIV that is located on external page. It is possible to do this using this kind javascript code?

    

        
6条回答
  •  一向
    一向 (楼主)
    2021-02-04 17:58

    Since it looks like you are using jQuery, something like this should be pretty close:

     var html;
     $.get("my_page.html", function(data){
         html = $(data).find('#glr1').html();
     });
    

提交回复
热议问题