0

I have a div element:

<div class="page">
        //some contents
</div>

CSS:

.page{
    bottom: 0;
    color: #1f1f21;
    font-size: 17px;
    font-weight: 400;
    left: 0;
    overflow: visible;
    position: absolute;
    right: 0;
    top: 0;
}

Getting screen height with JavaScript:

var page_height = screen.height;
alert(page_height);

How can I apply this page_height value to my .page class?

(i.e) I need to set screen height to my page class

For example, if screen.height = 405

I need to add height property

height: 405px;
TylerH
  • 20,799
  • 66
  • 75
  • 101
UI_Dev
  • 3,317
  • 16
  • 46
  • 92

2 Answers2

1

Use .height():

$('.page').height(page_height);
Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
-1

Try this Fiddle

var page_height = screen.height;
$('.page').height(page_height)
alert(page_height);
.page{
    bottom: 0;
    color: #1f1f21;
    font-size: 17px;
    font-weight: 400;
    left: 0;
    overflow: visible;
    position: absolute;
    right: 0;
    top: 0;
    width:500px;
    background:green;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.0/jquery.min.js"></script>
<div class="page">
        //some contents
</div>
Akshay
  • 14,138
  • 5
  • 46
  • 70