Skip to content Skip to sidebar Skip to footer

Add Height On Click With Javascript

I am having a hard time figuring out how to add height to my div. Considering this Html :
add height

Solution 1:

you have not to assign new height to element try below code

functionresize() { 
 //get elementvar height=document.getElementById('box').style.height;

 //transform element from string to integer

 height=height.replace("px","");
  height=+height;

  //change heightvar n=height;
  height=n+300+'px';        
 document.getElementById('box').style.height = height;
}

Solution 2:

add this at the end of your code

document.getElementById('box').style.height = height

Solution 3:

See this : Sample fiddle

You missed:

document.getElementById('box').style.height = height

Post a Comment for "Add Height On Click With Javascript"