load different div with different conten and not reload the page?

Posted by Lars Holmqvist on Stack Overflow See other posts from Stack Overflow or by Lars Holmqvist
Published on 2013-11-06T13:43:53Z Indexed on 2013/11/06 15:53 UTC
Read the original article Hit count: 184

Filed under:
|
|

I have the following code to load different div with different content by clicking on a link. My question is how can I write so that not reload the page every time I click on a link.

#content > div {
    display: none;
}
#content > div:target {
    display: block;
}
<a href="#div1">Div one</a>
<a href="#div2">Div two</a>
<a href="#div3">Div three</a>
<a href="#div4">Div four</a>

<div id="content">
    <div id="div1">This is div one</div>
    <div id="div2">This is div two</div>
    <div id="div3">This is div three</div>
    <div id="div4">This is div four</div>
</div>

© Stack Overflow or respective owner

Related posts about div

Related posts about href