My aim is to create a navigation menu using jquery. when the user rollover over left1, right 1 should appear and so forth. I am trying to code this in jquery but i am a little tied up. please assist
css
.left {
background: #fff;
padding: 10px;
width: 200px;
border: 1px solid #ccc;
position:relative
}
.right{
background:aqua;
height:270px;
width:200px;
float:right;
visibility:hidden
}
html
<div class="left" id="left1">left 1</div>
<div class="left" id="left2">left 2</div>
<div class="left" id="left3">left 3</div>
<div class="left" id="left4">left 4</div>
<div class="right" id="r1">right 1</div>
<div class="right" id="r2">right 2</div>
<div class="right" id="r3">right 3</div>
<div class="right" id="r4">right 4</div>
jquery
$(document).ready(function(){
function rightFrame(){
$('#r1').css({
'position':'absolute',
'top':'40px',
'left':'300px',
'visibility':'visible'
});
$('#r1').show();
}
$('#left1').mouseover(function(e){
$("#left"+ID).css('background','red');
});
$('.left').mouseout(function(e){
$('.right').hide();
});
});
my question may seem a little off but i hope you can understand my aim. thanks
You have a few fundamental problems here.
rightFrame()but you are not calling it anywhere in the script.$(this)to open and close menu items instead of IDs.Here is a Fiddle to show you an easy fix: http://jsfiddle.net/PFnDe/1/
EDIT: I guess I should post my JS here too.