Advertisement
Update: The icons used in this tutorial can be found free here.
There are many posts available detailing how to write your own jQuery plugin. It won’t take long before you realize that building in jQuery is very simple. Continuing in our jQuery Learning Series, here we’re going to build your first jQuery plugin. It’ll generate a bubble effect for your menu list and we’re going to call it BubbleUP.
What is BubbleUP? BubbleUP is a fun and easy plugin to get you started in jQuery. The effect is a nice starting point for learning the basics and many of the steps involved in creating other more intricate plugins you will make in the future. With this plugin, images in a list will enlarge with a smooth animation when you move your mouse over it. Then, if you move the mouse out, it will reset to the original size with the same smooth animation.
Like the article? Be sure to subscribe to our RSS feed and follow us on Twitter to stay up on recent content.
Implement jQuery
This is a plugin for jQuery, so we first have to implement the jQuery library in our webpage header (you must upload jQuery to your server or link to Google’s hosted version):
<script type="text/javascript" src="js/jquery-1.3.2.js"></script>
1. Choose a name
We will name this plugin as BubbleUP, but feel free to choose another name that suits you better.
In building a jQuery plugin, it’s recommended you write all the plugin code in one javascript file. Your jQuery plugin’s file should be named as: [Your-jQuey-Plugin-Name].jQuery.js, but if it’s too complicated for you, just name it as: bubbleup.js.
Now, we’ll start with a blank javascript file and begin with the following lines (the template for any jQuery plugin):
(function($){ Â Â Â Â $.fn.BubbleUP = function() { Â Â Â Â Â Â Â Â return this.each(function() { Â Â Â Â Â Â Â Â }); Â Â Â Â }; })(jQuery);
We named the plugin above “BubbleUP“, so we are going to define the name of this plugin by using this code:
...
    $.fn.BubbleUP = function() {
...Because we have more than one item in our list, we have to use the each() function to execute the called function for every item in our list.
The first step is finished: creating the jQuery plugin template and naming it.
2. Implement jQuery Plugin to web page
Now you need to link the javascript file that you created above into your web page. For this, we’ll use this code:
<script type="text/javascript" src="js/bubbleup.jquery.js"></script>
To make the plugin work, we need to use this code below. You can insert it anywhere you want as long as it’s inside the <head> or <body> tags:
<script type="text/javascript"> $(function(){ Â Â Â Â $("ul#menu li img").bubbleup(); }); </script>
As you can see in the demo, we are going to enlarge the image in the list. That’s why we use images in this menu as target elements.
3. Animate
Let’s write the skeleton of the code. We’re going to use the mouseover(), mouseout(), animate(), and stop() functions.
(function($){ Â Â Â Â $.fn.bubbleup = function() { Â Â Â Â Â Â Â Â return this.each(function() { Â Â Â Â Â Â Â Â Â Â Â Â $(this).mouseover( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â function () { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).stop(); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).animate({ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ... Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â Â Â ).mouseout( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â function () { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).stop(); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).animate({ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ... Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â Â Â ); Â Â Â Â Â Â Â Â }); Â Â Â Â }; })(jQuery);
This code basically says this: “Upon mouseover or mouseout, stop any animations that are currently active in this element, and start a new animation (which we’re going to define later)”. We need to immediately stop active animations first to prevent undesirable behavior. This function stop() will stop the animation before it starts the new animation. The function we are using to generate the smooth bubble effect is animate().
4. Build the menu
We need to build the menu using HTML. The menu is an unordered list, so it should be something like below. Notice this list has been simplified for this tutorial.
<ul id="menu"> Â Â <li> Â Â Â Â <a href="#" title="Full RSS Feed"> Â Â Â Â Â Â Â Â <img src="images/rss.png" alt="Full RSS Feed"> Â Â Â Â </a> Â Â </li> Â Â <li> Â Â Â Â <a href="#" title="E-Mail Delivery"> Â Â Â Â Â Â Â Â <img src="images/email.png" alt="E-Mail Delivery"> Â Â Â Â </a> Â Â </li> Â Â <li> Â Â Â Â <a href="#" title="Follow me on Twitter"> Â Â Â Â Â Â Â Â <img src="images/twitter.png" alt="Follow me on Twitter"> Â Â Â Â </a> Â Â </li> Â Â <li> Â Â Â Â <a href="#" title="I'm on FaceBook"> Â Â Â Â Â Â Â Â <img src="images/facebook.png" alt="I'm on FaceBook"> Â Â Â Â </a> Â Â </li> Â Â <li> Â Â Â Â <a href="#" title="E-Mail Delivery"> Â Â Â Â Â Â Â Â <img src="delicious.png" alt="Save it!"> Â Â Â Â </a> Â Â </li> Â Â <li> Â Â Â Â <a href="#" title="E-Mail Delivery"> Â Â Â Â Â Â Â Â <img src="images/technorati.png" alt="Favorite this blog"> Â Â Â Â </a> Â Â </li> </ul>
This HTML code is very simple. You need to create just one image for each item and the jQuery plugin will do the rest. The next step is the CSS.
5. Style the menu (CSS)
The following CSS is used to style the menu. There are two important things that you should notice: position for <li> elements must be set to relative because img elements inside it must be set as absolute. Absolute positioning for an element will not work if the parent is not set as absolute or relative.
The original size of the images is 48px in this tutorial, and the size when enlarged is 96px. That means the images will start animation at 48px and enlarge to 96px. Some margins and padding is in this css code below just make the list display better.
ul#menu {
    margin: 5px 0px;
}
ul#menu li {
    padding: 0px;
    display: inline-block;
    *display: inline; /* IE 7 and below */
    position: relative;
    margin-left: 5px;
    margin-right: 5px;
    width: 48px;
    height: 48px;
}
ul#menu li img {
    width: 48px;
    position: absolute;
    top: 0px;
    left: 0px;
    padding: 0px;
    margin: 0 8px 0 0;
    border: none;
}6. Create the animations
This is the main part of this plugin. We will pass some parameters to the animate function.
First, I strongly recommended you re-read one of our previous articles,Bubble Effect with CSS. When you return to this post, you will understand why we need to enlarge the image and move it up and left the way we are.

As you can see, we need to re-size the images in menu to make it larger. The original size is 48px; the animate function will re-size it to 96px. Take a look in detail at the javascript code below:
(function($){ Â Â Â Â $.fn.bubbleup = function() { Â Â Â Â Â Â Â Â return this.each(function() { Â Â Â Â Â Â Â Â Â Â Â Â $(this).mouseover( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â function () { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).stop(); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).animate({ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â left: "-=24", Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â top: "-=24", Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â width: 96 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }, 'fast'); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â Â Â ).mouseout( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ... Â Â Â Â Â Â Â Â Â Â Â Â ); Â Â Â Â Â Â Â Â }); Â Â Â Â }; })(jQuery);
We will place this image by using negative pixel amounts. The code above will listen for a mousehover() event. When the mouse is over the item, the item will be moved diagonally towards to the top left corner by 24 pixels and then also enlarged to 96px.
However, we have a few issues right here. The problem is the action for this image will cover the image next in the list. Thus, we need to set z-index for it by using css. We also need to reset the placements of all the images before and after the animation, because if the animation is not completed and we move the mouse out and over again immediately, the image will be moved once again diagonally towards the top left corner. We must understand that the amount of pixel this image animates base on the current position + (-24px)
The complete javascript code that helps the animation to work correctly:
(function($){ Â Â Â Â $.fn.bubbleup = function() { Â Â Â Â Â Â Â Â return this.each(function() { Â Â Â Â Â Â Â Â Â Â Â Â $(this).mouseover( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â function () { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).stop(); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).css({'z-index' : 100, 'top' : 0, 'left' : 0, 'width' : 48}).animate({ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â left: "-=24", Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â top: "-=24", Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â width: 96 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }, 'fast'); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â Â Â ).mouseout( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ... Â Â Â Â Â Â Â Â Â Â Â Â ); Â Â Â Â Â Â Â Â }); Â Â Â Â }; })(jQuery);
We do something similar with the mouseout() event, but it has a few differences. Of course, the images must be placed back to the original position and re-sized back to the initial size. However, we need to call a new function when the animation is completed. The callback function is used to reset the z-index to the original.
(function($){ Â Â Â Â $.fn.bubbleup = function() { Â Â Â Â Â Â Â Â return this.each(function() { Â Â Â Â Â Â Â Â Â Â Â Â $(this).mouseover( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ... Â Â Â Â Â Â Â Â Â Â Â Â ).mouseout( Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â function () { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).stop(); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).animate({ Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â left: 0, Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â top: 0, Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â width: 48 Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â }, 'fast', function() { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $(this).css({'z-index' : 0}); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ); Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â Â Â Â Â Â ); Â Â Â Â Â Â Â Â }); Â Â Â Â }; })(jQuery);
7. Add option(s)
I know there some great tutorials out there help you make a jQuery Plugin with options supported, but this one is different. The difference is not the content, because there are many ways to add options to it, it’s just a change of the code format. The difference here is in the value of this plugin – it is not just a tutorial, but is actually useful.
In this part, I will help you add options for your menu BubbleUp. So, stop right here and think about the options we might require. How about the tooltip? We can add the tooltip for this over the top of each item when the mouse is hovering over it. Let’s begin!
First, write a draft for it, as a template. jQuery plugins should have default options and users will decide to use these options or not. Change the code to this template:
(function($){     $.fn.bubbleup = function(options) {         //Extend the default options of plugin         var opts = $.extend({}, $.fn.bubbleup.defaults, options);         //Initial the tooltip         var tip = null;         return this.each(function() {               //Set the option value passed here             var $tooltip = opts.tooltip;             $(this).mouseover(                 function () {                     if($tooltip) {                         //Display the tooltip                                             }                                   $(this).stop();                     $(this).css({                         'z-index' : 100,                         'top' : 0,                         'left' : 0,                         'width' : 48                     }).animate({                         left: "-=24",                         top: "-=24",                         width: 96                     }, 'fast');                 }             ).mouseout(                 function () {                     if($tooltip) {                         //Hide the tooltip                                             }                               $(this).stop();                     $(this).animate({                         left: 0,                         top: 0,                         width: 48                     }, 'fast', function() {                             $(this).css({'z-index' : 0});                         }                     );                 }             );         });     };     //All default options go here     //Must called     $.fn.bubbleup.defaults = {         tooltip: false     } })(jQuery);
When you mouse-over
This tooltip will display in the same way as other plugins. When you mouse-over, the tooltip will show up and when the mouse is moved away, the tooltip will be invisible.
Add this code to the mouseover() code block and inside the tooltip is this enabled condition:
if($tooltip) { Â Â Â Â tip = $('<div>' + $(this).attr('alt') + '</div>'); Â Â Â Â tip.css({ Â Â Â Â Â Â Â Â color: '#333333', Â Â Â Â Â Â Â Â fontSize: 12, Â Â Â Â Â Â Â Â fontWeight: 'bold', Â Â Â Â Â Â Â Â position: 'absolute', Â Â Â Â Â Â Â Â zIndex: 100000 Â Â Â Â }); Â Â Â Â tip.remove().css({ Â Â Â Â Â Â Â Â top: 0, left: 0, Â Â Â Â Â Â Â Â visibility: 'hidden', Â Â Â Â Â Â Â Â display: 'block' Â Â Â Â }).appendTo(document.body); Â Â ... }
We will not use any external CSS, but instead style the tooltip with JavaScript. This code will create a new tooltip which uses the value of the image’s alt attribute. We put it in the div tag to display, then put the tip at the end of the HTML document.
Next, we will display the tip:
if($tooltip) {   ...     //Get the width and height of current image item     var position = $.extend({}, $(this).offset(), {         width: this.offsetWidth,         height: this.offsetHeight     });     //Get the width and height of the tip element                       var tipWidth = tip[0].offsetWidth,         tipHeight = tip[0].offsetHeight;     //Set position for the tip to display correctly     //Postion: top and center of image            tip.stop().css({         top: position.top - tipHeight,         left: position.left + position.width / 2 - tipWidth / 2,         visibility: 'visible'     }); }
However, our image will scale from small size to big size when we mouse-over. If the tip won’t move together with the image, then one of them will be covered by the other. The one that would be covered is the one that has the lower value of z-index.
That’s why we need to animate the tip:
if($tooltip) {
  ...
   tip.animate({
       top: "-=24",
   }, 'fast');
}When the mouse is away
When the mouse is away, the code is very simple. We just need make the tip visible. However, we should remove it then create and create another one when the mouse is over it again. That’s better than just setting it to be invisible.
if($tooltip) { Â Â Â Â tip.remove(); }
You’re done!
That’s all you need to make a jQuery plugin!
Please understand that this is just a basic version of BubbleUP and it still has some issues. If we are going to create a complete jQuery plugin, we should do more. Creating a jQuery plugin by yourself is very easy if you know the basics of jQuery, and it is easier if you are creating a practical plugin, like BubbleUP, to understand the steps.
Are you going to use it on your site? It is quite a smooth and simple menu, isn’t it? Tell us how you’re using it on your website in the comments and don’t forget to subscribe to the feed!
Advertisement
You May Also Like
Related Articles



Demo link is not working Lam
Smashing Share´s last blog ..10 Useful Web Design and Development Books
ouch, sorry! Updated it, thanks friend!
Cool. Nice effect
Smashing Share´s last blog ..10 Useful Web Design and Development Books
Wow, very slick thanks!
Dimi´s last blog ..Learning jQuery: Your First jQuery Plugin, “BubbleUPâ€
“If it doesn’t work on IE 6, I don’t care!”
Love it!
I would love to have a t-shirt with this in HUGE letters.
Also a massive poster above my desk as well.
It’s my new mantra. Thanks very much.
I just wish my employer felt the same way.
Yah, that’s a good idea with the t-shirt
It means you must attend this funeral ie6funeral.com/ LOL
Anyway thank you so much Lam for useful tuts!

Hidayat Sagita´s last blog ..Krumo : Debugging in Human Readable Information
I belong! IE 6 is really a big problem in web developing.
Love the qoute “IF it doesn’t work on IE 6, I don’t care!” but we still have to consider IE 6 in every code we’re doing.Too bad!
Nice work, I actually never bothered to make my own jQuery plugin, but this time I will give it, a try.
Mostly because it looks simple so it won’t take long, which is great since I have like NO time, heh
. Thanks.
Michal Kozak´s last blog ..michalkozak: RT @amberweinberg: Multiple Class / ID and Class Selectors http://css-tricks.com/multiple-class-id-selectors/
Flipping great article, thanks Lam. I’ve been toying with the idea of diving into jQuery, but haven’t really found a tutorial that helps.
Have bookmarked this for future reading. Thanks again!
Omg This Is Amazing !!!
Great stuff. .. thanks for sharing..
I love working with jQuery, excellent share Lam.
FAQPAL´s last blog ..CSS Graphs And Charts: 11 Hand-picked Tutorials And Solutions
wow Wow Wooooow WOOOw Lam
this is good article and tutorials
me will try it
thank’s Lam
me ReTweet this for u 
I´m a big fan of jQuery that first :p
Now can´t you do this with the CSS3 scale property? Why bother with so much jQuery code?
Hi Dario, yes we can do the bubble effect with scale property in CSS3, but where’s the tool tip?
And when CSS3 can be used widely in all major web browsers?
Cool article, thanks. A few minor changes makes it work in IE 6. I think everyone agrees that IE6 sucks but it’s still used so what can you do. Thanks again.
Lam this is great stuff man. Good job.
From the download page: This user is not allowed to use direct links. ?
What do you mean?
Great stuff. There is a plugin named fliphover to do the same. You can pass the amount of zoom, rollover image etc,,..
http://www.decodize.com/jquery/fliphover
praveen vijayan´s last blog ..Fliphover
Great tutorial – is that a free social media icon set you have used. I like it very much can you post a link?
thanks
Great and nice. I’ve optimized your version a bit. You’ve got much more options (scale, fontFamily, color, fontSize, fontWeight, inSpeed, outSpeed), and you can use it with any picture, no matter what size.
http://w.jonnitto.ch/bubbleup
Thanks, care to tell our readers how to use your version of the plugin and how you changed it?
Wow, cool! That’s really cool when my plugin was optimized for better. Thanks Jonathan! I love the way you did for the in/out speed. That would be better for a realistic bubble effect than the old one, right?
What do you think if I complete it and also the manual for it? Wow, that would be a nice plugin which written in collaboration.
Cheer!
Yeah, shure!
Lam, great article and very detailed! The final effect is great as well. I think the one point I would argue with you on is that removing the tip is better than hiding it. DOM manipulation is always one of the most expensive operations JS code can make, so I would say it would be better to create it once, then show/hide it with CSS or JS. But removing and adding it again seems costly.
Either way, keep writing great articles like this. Its really top notch!
Doug Neiner´s last blog ..Old Mill Texture Pack Free Download
Hi Doug,
Thanks for your kind comment. I’m gonna write it as a complete jQuery Plugin, so I will keep your suggestion in mind. Cheer!
Your demo is broken.
Error: $(“div#demo ul#menu li img”).bubbleup is not a function
Source File: http://aext.net/jquery-menu-plugin-bubbleup/
Line: 130
Sorry, the jQuery library was conflicted with other library. Fixed it!
not work on IE
Which version of IE?
IE7 and IE6 via IETester on WinXP, also Compat mode in IE8 fails.
All kinda stack the icons one on top of other.
The javascript error is: Line 62 Char 13 Expected identifier, string or number.
Would be good to support IE7 at least.
Cool effect dude. Cheers
and another thing… Line 127 Char 5 Object doesn’t support this property or method. Ta.
Wow…. that’s so cool. jQuery is definitely the best thing that has happened to web design
Nice tutorial, I like the effect.
That’s perfect :
This seems like a perfect tutorial to get started on jQuery. I’ve been mainly copy/pasting without fully learning what I’m doing. Can’t wait to give this a try and integrate into my web site. Thanks and cheers!
It works like a charm on IE8, Chrome 4.0.266.0, and Comodo Dragon 1.0.0.9 too! Thx! =)
Great tutorial, thanks for sharing!
good website!
This is perfect, exactly what i was looking for!
thanks for sharing!!
Nice, but to working in IE7…
Lovely little effect just what I need on a Friday morning, very smooth action too…as far as writing the code myself, normally its just beyond me but you’ve explained it very well and I might just have a go this time cheers Lam.
Rory´s last blog ..Website Design Compatibility Checking
Hi, Lam
Nice script, but don’t work on IE7.
Do you already fix it?
Regads
Really? I will take a look asap and thanks for notify!
Awesome.but how to use them in wordpress site
TheShadow´s last blog ..Desire by Oliver Feng
You’ll have to edit your WordPress theme or turn it into a widget
hi Nathan,
how can i put icons in vertical and not in horizontal?
Gigi´s last blog ..Avatar disc opens up online-only extras until ultimate edition arrives in November, 3D next year
Change your CSS code!
Great stuff Lam! To fix the minor OPERA rendering bug (Opera 10 anyways) change the code in the return to normal size like this :
$(this).animate({ }, ‘fast’, function() {
$(this).css({‘z-index’ : 0, ‘left’: 0, ‘top’: 0, width: 48});
});
It won’t “bubble down” anymore, but it won’t leave the artifacts either and still works with all the browsers. You could probably do a “check browser type” and only do the above for Opera…but I don’t need the “bubble down” so I left if the same for all.
Also, if you changed all the hard-coded sizes to variables, like startwidth/bigwidth/growth (just like you did with the boolean tooltips) you could use any size images.
var $startwidth = opts.startwidth; /* i.e. 48 */
var $bigwidth = opts.bigwidth; /* i.e. 96 */
var $growth = ($bigwidth – $startwidth) / 2 /* half the difference between sizes i.e 24 */
Not to nitpick but if you put a class of “bubbleup_tip” in the tip DIV you wouldn’t have to define any of the styling in your JS. That could be left inside the CSS to create the styling.
Again, great stuff – just some comments to help.
Oh dear, you made my day! Just woke up and got your comment. I appreciate your comment, actually it’s a help. Sure thing that you will be personally noticed when the first version of this one is completed. Cheer!
No problem, glad it helped!
Any way to easily change the Font Color of the Tooltip?
New to this so a few steps would be great.
Thanks!
Thats great! thanks a lot for sharing this!
thanks for the share!
get your website optimized at Quintema
Rosie´s last blog ..Tracking Your Traffic Sources
Thanks alot. Works fine except that I noticed a bug.
In Firefox all goes well. But in browsers like Google Chrome or Midori when you just click a link and go to a page, the menu behaves just ok. But if you use browser’s refresh button and then hover over the images they just get smaller and smaller and disappear. Should you click some link on the website, when the page reloads it again behaves fine.
Using the back button after clicking on a link in Firefox, returns to the page with the item still in the “Up” position. This has something to do with the bfcache, and while I dont know a lot about it, the problem is fixed by adding window.onunload = function(){}; somewhere inside the script tags. Ex:
window.onunload = function(){};
$(document).ready(function() {
–SNIP–