html - Expand/Collapse div in javascript doesent work -


trying make script collapses/expands other div when click "main" div. both divs 100x100 if matters.

one 100px x 100px div contains onclick="myfunction()", other 1 plain html/css (id=box2).

function expand() {     document.getelementbyid("box2").style.height = "200px"; }  function collapse() {      document.getelementbyid("box2").style.height = "100px";  }  function myfunction() {     if (document.getelementbyid('otherbox').clientheight = 100) {       expand();     }      else { collapse(); }  } 

tried many different alternatives nothing works yet, suggestions? *edit: div expands, doesent collapse again when click again.

replace .clientheight = 100 .clientheight == 100

using = 100 sets value 100 returning true in if.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

jsf - How to ajax update an item in the footer of a PrimeFaces dataTable? -

django - CSRF verification failed. Request aborted. CSRF cookie not set -