문제

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