简体   繁体   中英

Javascript change div content

My site has a one <div> for the header, one for navigation-panel and one for the content.

For the navigation-links i use

<p class="blue"><label onclick="goFor('test')"> -> TEST! <- </label> </p>

and my JS:

function goFor(destination) 
{ 
    document.getElementById("content").load(destination+'.php'); 
}

in this case, the content-div should change to the file "test.php".

but Firebug says: document.getElementById(...).load is not a function

what am i doing wrong?

Use $("#content").load(something) instead of document.getElementById.

Or... make an ajax request and load answer in that div.

For an ajax request with no lib, you can check my script here (first answer): Insert external page html into a page html . Note the success handle as you want it... with document.getElementById.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM