I have a DIV:
<div class="div_tab" id="div3"> </div>
Its properties are defined:
.div_tab {
top:0;
position: sticky; /* make the table heads sticky */
display: inline-block;
height : 500px;
width :auto;
overflow-x: hidden;
overflow-y: auto;
border : 1px black solid;
padding:0;
margin-left: 10px;
margin-right:10px;
margin-bottom:5px;
}
It really have assigned height.
But when I change height:
this.tabDiv.setAttribute("height",px); // px is calculated
this.tabDiv.setAttribute("max-height", px);
Height does not change.
When I ask attribute value:
alert(this.tabDiv.getAttribute("height"));
I see value of "px".
How can I change div’s height?
2
Answers
setAttribute()
is typically used to set HTML attributes, not CSS properties:You can try using style property to set the CSS property like the following way:
try this way.