javascript - Show / hide menu does not work

0
function dpdShowHide(){
var orgBtn = getElementById('organizador');
var dpdOrg = getElementById('org-dpd-list');
    if (orgBtn !== false) {
        dpdOrg.visibility('none')
    }
    else{
        dpdOrg.visibility('block')
    }
}

So, my problem is this, I'm trying to make a hidden menu (an ul) appear and disappear when I click on the li (parent element of that other ul), but it is not working

    
asked by anonymous 07.06.2016 / 14:50

1 answer

0

Will this be?

<script>
function dpdShowHide(ele){

    dpdOrg = ele.children[0];
    if (dpdOrg.style.display == 'none') {
        dpdOrg.style.display = 'block';
    }
    else{
       dpdOrg.style.display = 'none';
    }
}

var orgBtns = document.getElementsByClassName('organizador');
for (var i = 0 ; i < orgBtns.length; i++) {
    orgBtns[i].addEventListener('click', function() {
       dpdShowHide();
    });
}

</script>

<ul>
       <li>
          li
       </li>
       <li class="organizador" onclick="dpdShowHide(this)">sub ul1
           <ul id="org-dpd-list" style="display: none">
              <li>sub li</li>
              <li>sub li</li>
           </ul>
       </li>
       <li>
          li
       </li>
       <li class="organizador" onclick="dpdShowHide(this)">sub ul2
           <ul id="org-dpd-list" style="display: none">
              <li>sub li</li>
              <li>sub li</li>
           </ul>
       </li>
    </ul>
    
07.06.2016 / 15:08