I was searching for Lavalamp menu solution and I found this little script. I am not sure if that's the best one around but looks nice and can be easily modified.

However it contain one error in console and I don't like errors so any help would be appreciated.

Uncaught TypeError: Cannot read property 'left' of null

Lavalamp Menu Original Source

Lavalamp Menu Fix JS Fiddle

You can go to that JS Fiddle fix and see in console when going through the menu it will show that property error.

I don't know how to resolve this, so any tips ?

有帮助吗?

解决方案

fixed it like so inside the 'mouseleave' branch:

        if ($this.siblings('li.active').offset()) {
            left = $this.siblings('li.active').offset().left - ($this.closest('.' + lavalamp).offset().left);
            width = $this.siblings('li.active').width();

            $this.closest('ul').next('div.floatr').css({
                "width": width + "px",
                "left": left + "px"

            });
         }

其他提示

It is due to line 35 of the javascript section of the fiddle.

$this.siblings('li.active')

Does not return anything, which is why the Chrome debugger returns the error Cannot read property 'left' of null

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top