javascript - Div doesn't stay visible -


i have 4 links. when click first link div 1 should displayed , other 3 hidden.
when click link 2, div 2 should displayed , other 3 hidden, , on...

what did:

  • with css i've set class of 4 divs display: none

  • created 4 functions javascript set display property of correct div block , 3 others none

  • call function when clicking link

when click link, div shown quarter of second disappears again

css:

.catdiv {     display:none; } 

js function:

function showkadoballonnen() {     document.getelementbyid("kadoballonnen").style.display = "block"     document.getelementbyid("geschenkmanden").style.display = "none"     document.getelementbyid("pampercadeaus").style.display = "none"     document.getelementbyid("origineleverpakkingen").style.display = "none"; } 

calling function:

<a href="" onclick="showkadoballonnen()">kadoballonnen</a> 

div has called:

<div id="kadoballonnen" class="catdiv">test</div> 

function showkadoballonnen(e) {    e.preventdefault();    document.getelementbyid("kadoballonnen").style.display = "block";    document.getelementbyid("geschenkmanden").style.display = "none";    document.getelementbyid("pampercadeaus").style.display = "none";    document.getelementbyid("origineleverpakkingen").style.display = "none";  }
.catdiv {    display: none;  }
<a href="#" onclick="showkadoballonnen(e)">kadoballonnen</a>    <div id="kadoballonnen" class="catdiv">test</div>  <div id="geschenkmanden" class="catdiv">test</div>  <div id="pampercadeaus" class="catdiv">test</div>  <div id="origineleverpakkingen" class="catdiv">test</div>

what missing?

all easier think. in tag got "href" empty parameter. makes page reloading while pressing on it. should write "#" parameter.

<a href="#" onclick="showkadoballonnen()">kadoballonnen</a> 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -