0

I am trying to put footer at bottom.I get screen height by js and put this value in a variable. Now i want to put this variable in css height.(How can i apply height 700px to heightscr, please see code below) Thanks

<script type="text/javascript">
    function footerlocation(){
        var heightscr=(screen.availHeight); 

        var myElement = document.querySelector(".container");
        myElement.style.height = "700px";
        myElement.style.backgroundColor = "#ff0000";        
    }
  </script>
2
  • Note that the () you have around screen.availHeight don't do anything. Commented Jan 27, 2017 at 12:32
  • I am unsure if screen.availHeight does anything at all. You give anything in JS a value with an = operator. LHS (left hand side) becomes what follows the operator, so: myelement.height = heightscr would make myelement's height property the value of heighsc variable. Commented Jan 27, 2017 at 12:33

1 Answer 1

2

String concatenation:

myElement.style.height = heightscr + "px";
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks T.J. Crowder for help me.I got what i want. Thnks

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.