Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9185167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T19:13:29+00:00 2026-06-17T19:13:29+00:00

I am trying use jquery to set the height of an element to equal

  • 0

I am trying use jquery to set the height of an element to equal the users browser. Here is the code I got so far that’s not working. Is it because I have a minimal height set in css? I really need that class to equal the users resolution.

<script type="text/javascript">
jQuery(function() { 
    jQuery(".bg").css("height", jQuery(window).css("height"));
}
</script>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T19:13:30+00:00Added an answer on June 17, 2026 at 7:13 pm

    Set a variable to window.innerHeight

    $(document).ready(function() {
        var height = window.innerHeight;
        $(".bg").css("height", height);
    });
    

    See: https://developer.mozilla.org/en-US/docs/DOM/window.innerHeight for more details on window.innerHeight.

    window.innerHeight returns the height of the user’s viewport, not really the screen resolution, as you were asking, but it works. There is also window.innerWidth and other methods of grabbing the user’s screen statistics.

    You can also use self.innerHeight, parent.innerHeight, and top.innerHeight but these have different purposes. (See link).

    Also, you’re using $(window).css("height"); The jQuery css() function assigns css values, it doesn’t return a string. It would be $(window).height() because height() does return a string.

    var height = function() { return this.length; }
    // height() returns "this.length"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use jQuery to set the height of several divs to all
I'm trying to use jQuery to get current window height. I intend to set
Im trying to use a Web Service to set an Airport code using Jquery
I am need paint my image. I'm trying use JQuery in here this link:
I'm trying to use Jquery to pass the value of one box that already
I am trying to use jquery to set the input field value to the
I'm trying to get jQuery to calculate the height of an element, and then
I'm trying to use jQuery to pass a height to colorbox. Doing so, the
I am trying to set the width and height of a div exactly equal
I'm trying to use jquery to set the class of all visible elements of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.