How do I disable the other onclick event once one of them has been activated. Both divs are set to display:none; in the CSS. This is probably really simple but I am new to programming.
HTML
<a id="leftbutton" href="#" onclick="showDiv(this.id); return false;">click me</a>
<a id="righttbutton" href="#"onclick="showDiv(this.id); return false;">click me</a>
Javascript
function showDiv(id)
{
if(id == "leftbutton"){
document.getElementById('orangediv').style.display = 'block';
}else{
document.getElementById('greendiv').style.display = 'block';
}}
Just set the onclick property of the other element to null;
this should do the trick:
You can set the href attribute as id of div which should be visibled after you click.
showDiv
function can get entire element as argument, then you have access to it attributes as well. Second argument can be a id of element you should hide,And in js:
Like this for example:
You could test if the other element is displayed :
Something along these lines: