Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone

I am working on a piece of code where I need to fill some points (text) in a div which acts as an accordion. I implemented it using the code below.
I achieved the desired output but when the points increase in numbers and goes above the height 50px, I loose some data. I dont want a scroll bar. I want to increase the height of the div.
Can I achieve the output using min-height?
I tried with
var tp1 = parseInt(document.getElementById("div1").style.minheight);
but it did not work.

Please help

Thankyou

JavaScript
 <script>
function doev1() {
var tp1 = parseInt(document.getElementById("div1").style.height);
if (tp1 > 0) {
document.getElementById("div1").style.height = "0px";
}
else 
{                                                   document.getElementById("div1").style.height = "50px";
}
}
</script>
Posted

1 solution

have u use like this
document.getElementById("myDIV").style.minHeight="100px";

I have noticed that in "minHeight" h is small in your syntax
 
Share this answer
 
Comments
JPais 13-Oct-14 15:09pm    
Hi..
Sorry it was a mistake withthe h. But yes I have tried it, it did not work.
VC.J 13-Oct-14 15:26pm    
the java script you have provided is working good
I use this code to call
More >>>
<div id="div1" style="height:10px;"></div>
and the logic is running fine in your script
so where do you getting the error
JPais 14-Oct-14 1:48am    
Yes the javascript is working well. But when I fill the div myDIV with content, I want the div to expand in height and not restrict to 50px.

I tried
document.getElementById("div1").style.height = document.getElementById("div1").style.minHeight;
But it didn't work.
I guess iits not the right way.
VC.J 14-Oct-14 3:01am    
what min height you have set
I think you get confused in min height and height
min height is use to set the minimum height of element
read this
http://www.w3schools.com/cssref/pr_dim_min-height.asp

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900