If you are using this lavalamp plugin, you'll need to use trigger()
to activate the mouseenter and click events... here is a demo.
HTML
<ul id="menu">
<li><a href="#home">Home</a></li>
<li><a href="#work">Work</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<br>
<a class="contact" href="#contact">contact me!</a>
Script
$(document).ready(function(){
$('ul#menu').lavaLamp();
$('.contact').click(function(){
$('#menu a[href*=contact]').parent().trigger('mouseenter').trigger('click');
return false; // added to prevent propogation
});
});
LOL, ok, since you are using the other lavalamp plugin... here is the code you can use. Also, since the lavaplamp plugin provides a click function, I have made the javascript unobtrusive by adding the function there (new demo).
HTML
<ul class="lavalamp">
<li class="current"><a href="#home">Home</a></li>
<li><a href="#work">Work</a></li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
<br><br><br>
<div id="home" class="info">
Home page stuff goes here.
</div>
<div id="work" class="info">
Work information goes here.
</div>
<div id="about" class="info">
About me.
</div>
<div id="contact" class="info">
Contact me.
</div>
<br><br><br>
<div class="links">
You can see my <a href="#work">work</a> or <a href="#contact">contact me.</a>
</div>
Script
$(function() {
// set up lavalamp
$(".lavalamp").lavaLamp({
fx: "backout",
speed: 700,
click: function(event, menuItem) {
// change information box
var $block = $( $(menuItem).find('a').attr('href') );
$('.info').not($block).hide();
$block.fadeIn();
return false;
}
});
// initialize information box
$('.current').trigger('click');
// make links outside of the lavalamp work
$('.links a').click(function(){
var block = $(this).attr('href');
$('.current').removeClass('current');
$('.lavalamp').find('a[href=' + block + ']').parent().trigger('click');
});
});