lopu lopu - 4 months ago 10x
Javascript Question

javascript selector with outerheight function isn't returning anything, and I can't select the selector anywhere else either

I've been trying to debug this in chrome dev tools but the variables for topMenuHeight and scrollItems are just always null or with length 0 so empty. One variable is literally just $(selector).outerheight() and it is returning null. I know for absolute sure that the html ul has the proper ID, anyway, here's all the codee

So we've got the nav:

<ul id="navmenu">
<li><a href="#splash"><i style="padding-right: 5px;" class="fa fa-home"></i>Home</a><div></div></li>
<li><a href="#about">Ordering</a><div></div></li>
<li><a href="#designs" target="_blank">Designs</a><div></div></li>
<li><a href="#hotels-resorts" target="_blank">Hotels / Resorts</a><div></div></li>

and some js

var lastId,
topMenu = $("#navmenu"),
topMenuHeight = topMenu.outerHeight()+15,
// All list items
menuItems = topMenu.find("a"),
// Anchors corresponding to menu items
scrollItems = menuItems.map(function(){
var item = $($(this).attr("href"));
if (item.length) { return item; }


var navHeight = $("#navmenu").outerHeight(true) ;

// Bind to scroll
// Get container scroll position
var fromTop = $(this).scrollTop()+navHeight;

I really can't figure it out, I'm pretty good at python but from what I can tell this selector should be working........

Here's the local site anyway


I checked and debugged your website. You should use

    //place your js here