Function to change Height with errors

Asked

Viewed 35 times

0

184 function bannerPrincipal(){
185     var bannerHolder = document.getElementById("banner-principal");
186     var windowSize = window.innerHeight;
187     bannerHolder.css.height == windowSize+"px";
188 }bannerPrincipal();

I am trying to change the height of the div "banner-main" with the above code, however, on the console appears the following error:

Uncaught Typeerror: Cannot read Property 'height' of Undefined at bannerPrincipal (index.php:187) at index.php:188

How can I fix the problem ? and what is causing it ?

  • }bannerPrincipal(); - What’s the idea of that line? It was a mistake to copy here?

  • 2

    @Sergio is an IIFE "Abajara".

1 answer

3


bannerHolder.css.height == windowSize + 'px';

should be

bannerHolder.style.height = windowSize + 'px';
  • 1

    in that passage bannerHolder.css.height == windowSize+'px' you are comparing in condition or adding value?

  • 1

    It is @Luizaugustoneto, I hadn’t noticed. I edited the answer.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.