How to load an html inside main index html on button click

后端 未结 2 688
别那么骄傲
别那么骄傲 2021-01-15 19:50

Use case:

I have designed a sidbar navigation using HTML and CSS\\Js as shown below. lets name this index.html

I

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-15 20:15

    You can use this on click a tag.

    function load(file) {
    
         document.getElementById("content").innerHTML='';
    }
    

    If you use jquery change to $("#content").load("flex.html");

    Update:

    If you try to open html file in local, you need setup security for browser allow enable CORS. Disable same origin policy in Chrome

    You should use a web server to open file. I host sample in free host. It worked

    https://viethien.000webhostapp.com

    function load(file) {
         
         document.getElementById("content").innerHTML='';
    }
  • Dashboard
提交回复
热议问题