Recently, I've made a lavalamp plugin based on a nettuts tutorial and it worked well on my other site. I wanted to reuse it with my other site but I'm getting this error:
Uncaught TypeError: Cannot read property 'left' of undefined
I am a beginner with jQuery and I can't really find out how to fix it.
Code:
(function($){
$.fn.lavylamp = function(options)
{
options = $.extend({
overlay: 20,
speend: 300,
reset: 1500,
color: '#78C2FF',
easing: 'easeOutExpo',
}, options);
return this.each(function(){
var nav = $(this),
currentPageItem = $('#active', nav),
cursor,
reset;
$('<li id="blob"></li>').css({
width: currentPageItem.outerWidth(),
left: currentPageItem.position().left,
top: currentPageItem.position().top,
backgroundColor: options.color,
}).appendTo('#nav');
blob = $('#blob', nav);
$('li', nav).hover(function(){
blob.animate(
{
left: $(this).position().left,
width: $(this).width()
},
{
duration: options.speed,
easing: options.spped,
queue: false
}
);
}, function(){
clearTimeout(reset);
blob.stop().animate({
left: $(this).position().left,
width: $(this).width()
}, options.speed);
reset = setTimeout(function(){
blob.stop().animate({
width: $(this).outerWidth(),
left: $(this).position().left,
}, options.speed);
}, options.reset);
});
});
}
})(jQuery);
And the error applies to this part:
$('<li id="blob"></li>').css({
width: currentPageItem.outerWidth(),
left: currentPageItem.position().left,
top: currentPageItem.position().top,
backgroundColor: options.color,
}).appendTo('#nav');
Could someone please give me a hint?
EDIT
HTML
<ul id="nav" class="unstyled inline">
<li><a href="">Start up Business</a></li>
<li><a href="industries.php=2">Entrepreneurial & Familit Owned Business</a></li>
<li><a href="">Hight Net Worth Individuals</a></li>
<li><a href="careers.php=1">Professionlas</a></li>
<li><a href="industries.php=8">Real Estate Professionlas</a></li>
<li><a href="industries.php=7">Not For Profit</a></li>
</ul>