How to put a whole html page in a div using jquery?

前端 未结 8 1464
暗喜
暗喜 2021-01-05 13:03

First of all I want everyone to know that I am absolute beginner so please be patient with me.

I want to know how am I going to put the entire html page in a div. I t

相关标签:
8条回答
  • 2021-01-05 13:18

    replace

    $("#directors").html("directors.html"); 
    

    with

    $("#directors").load("directors.html");
    

    the html file that you load should only contain the contents of the DIV - ie not the <head> the <body> or even the navigation - just the content

    0 讨论(0)
  • 2021-01-05 13:22

    using your code you fill the html code with a constant string "footballplayer.html".

    You can use the load method, here is an example:

    $('#footballPlayers').load('footballplayers.html');
    

    it get via AJAX the page you request and fill the element.

    0 讨论(0)
  • 2021-01-05 13:25

    I'm on the load train:

    $("#div1").load("myhtmlpage.htm");
    
    0 讨论(0)
  • 2021-01-05 13:34

    You can use load for this:

    $("#div1").load("myhtmlpage.htm");
    
    0 讨论(0)
  • 2021-01-05 13:35

    You need to actually load the contents of footballplayers.html using AJAX, and then put that in the div.

    Try this:

    $("#footballPlayers").load("footballplayers.html");
    

    .load uses AJAX to get the page, then loads it into the div.

    0 讨论(0)
  • 2021-01-05 13:37

    use load

    jQuery("#footballPlayers").load("footballplayers.html");
    

    for more details click here

    0 讨论(0)
提交回复
热议问题