-2

My page isnt doing what i programmed the javascript to do is know the code i correct if i call expand() it works but not check()

function check(i) {
  if (document.getElementById(i).style.visibility == "hidden") {
    expand(i);
  } else {
    collapse(i);
  }
}

function expand(i) {
  document.getElementById(i).style.visibility = "visible";
}

function collapse(i) {
  document.getElementById(i).style.visibility = "hidden";
}
<div id="brand" onclick="check('brand-show')"> brand </div>
<div class="brand-show" id="brand-show" style="visibility: hidden">dcdv</div>

<div id="brand" onclick="check('brand-show')"> brand </div>
<div class="brand-show" id="brand-show" style="visibility: hidden">dcdv</div>

Please help i cant get the onlick to work in django for some reason.

David
  • 208,112
  • 36
  • 198
  • 279

1 Answers1

0

I don't see any issues with the Javascript at all. This code snippet hides/shows when you click the "brand"

function check(i){
  if (document.getElementById(i).style.visibility == "hidden"){
    expand(i);
  }
  else{
    collapse(i);
  }
}


function expand(i){
    document.getElementById(i).style.visibility = "visible";
}
function collapse(i){
    document.getElementById(i).style.visibility = "hidden";
}
<HTML>
<div id = "brand"   onclick="check('brand-show')"> brand </div>
<div class="brand-show" id = "brand-show" style="visibility: hidden" >dcdv </div>
</HTML>
Nathan Champion
  • 1,291
  • 1
  • 14
  • 23