Register

If this is your first visit, please click the Sign Up now button to begin the process of creating your account so you can begin posting on our forums! The Sign Up process will only take up about a minute of two of your time.

Results 1 to 3 of 3
Like Tree2Likes
  • 2 Post By TheGAME1264

Thread: jQuery outerHeight(); Returning null

  1. #1
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times

    [Solved] jQuery outerHeight(); Returning null

    Usually, when I have JS problems, it's a simple syntax error, but I'm stumped on this one.

    Why in the world would this:
    Code:
    var iconHeight = $('ul.icon-nav > li:first-child').outerHeight(true);
    be returning null?

    It definitely has a height, and even if it didn't, shouldn't it return 0?

    The API says outerHeight() returns "null if called on an empty set of elements". This has me thinking that maybe the selector isn't matching. But I don't understand why it wouldn't. For S's and G's, here's the HTML:
    HTML Code:
    <ul class="icon-nav">
    <li>        
    <a href="./#services">            
    <img src="/images/services.png" alt="Roe Designs Services" class="icon">            
    <div class="caption">Services</div>        
    </a>    
    </li>    
    <li>        
    <a href="./#portfolio">            
    <img src="/images/contact.png" alt="Roe Designs Porfolio" class="icon">            
    <div class="caption">Work</div>        
    </a>    
    </li>
    <!-- Repeat -->
    </ul>
    I've also tried a number of different possibilities for the selector, including:
    ul.icon-nav li
    ul.icon-nav > li
    ul.icon-nav li:first
    .icon-nav every combination of li above

    What, for the love of God am I missing?
    Last edited by Ronald Roe; Oct 05th, 2013 at 12:32 PM.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  2.  

  3. #2
    Senior Member Ronald Roe's Avatar
    Join Date
    Mar 2011
    Location
    Oklahoma City
    Posts
    3,141
    Member #
    27197
    Liked
    959 times
    Answer: because the JS was loaded in the <head>, it was trying to set the variable before the browser could calculate the value. I moved the script tag just before </body>, and it worked fine.
    Ron Roe
    Web Developer
    "If every app were designed using the same design template, oh wait...Bootstrap."

  4. #3
    Unpaid WDF Intern TheGAME1264's Avatar
    Join Date
    Dec 2002
    Location
    Not from USA
    Posts
    14,483
    Member #
    425
    Liked
    2783 times
    Glad we could help!
    Ronald Roe and AlphaMare like this.
    If I've helped you out in any way, please pay it forward. My wife and I are walking for Autism Speaks. Please donate, and thanks.

    If someone helped you out, be sure to "Like" their post and/or help them in kind. The "Like" link is on the bottom right of each post, beside the "Share" link.

    My stuff (well, some of it): My bowling alley site | Canadian Postal Code Info (beta)


Remove Ads

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Search tags for this page

jquery outerheight wrong

,

outerheight jquery return null

Click on a term to search for related topics.
All times are GMT -6. The time now is 09:17 AM.
Powered by vBulletin® Version 4.2.3
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.
vBulletin Skin By: PurevB.com