lavaLamp plugin - A way to change manually the selected element.

lavaLamp plugin - A way to change manually the selected element.

Hello all,

I haven't seen yet a way to change manually the selected element of a lavaLamp menu, so I have searched a solution and here it is :
  1. // Function to change the selected element of a lavaLamp menu.
  2. // You can use both the number of the li (starting with 0) or the li element itself.
  3. function lavaMove(el) {
  4.     if (!el && el !== 0) return false;
  5.     else if (/^[0-9]+$/.test(el)) el = $($("ul#menu > li").get(el));
  6.     el.trigger('mouseenter');
  7.     el.trigger('click');
  8.     return true;
  9. }

It's perhaps not the better way to do that, but it works fine for me, so I decided to share it ... Perhaps somebody will found his happiness with it ! ;)

Please feel free to make comments !
Nashii aka XaF