Disabling onclick attribute with javascript

前端 未结 7 736
梦如初夏
梦如初夏 2021-01-05 14:09

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 p

7条回答
  •  时光取名叫无心
    2021-01-05 14:46

    Something along these lines:

    function showDiv(id){   
    var o = document.getElementById('orangediv');
    var g = document.getElementById('greendiv');
    if  (id == "leftbutton"){
         o.style.display = 'block';
    }else{
        g.style.display = 'block';
    }
    o.writeAttribute('onclick','');
    g.writeAttribute('onclick','');
    }
    

提交回复
热议问题