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,816
  • 57
  • 73
  • 92
UI_Dev
  • 3,189
  • 14
  • 42
  • 89

2 Answers2

1

Use .height():

$('.page').height(page_height);
Milind Anantwar
  • 79,642
  • 23
  • 92
  • 120
-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
  • 13,805
  • 4
  • 42
  • 68