Hi there,
I'm having some trouble with closing / opening / moving divs.
The idea is that when i click on a persons name, to the right of that opens a div of about 400 x 400 which contains their biography.
Basicly, the persons names in the black boxes over in this example:
http://www.i-marco.nl/weblog/jquery-accordion-menu/#
and then when u click on the black 'link', it opens up 1 submenu item containing and img or anything. (so 1 <li><img src =' bla ' ></li>
And to the right as specified earlier, of about the same height as the div with biography titles and the 1 expanded picture at a time, which will initially not be visible ( since no person is selected yet. )
Ofcourse I have some jquery code, but Its not my best..
Now it just moves it to the right... >.<
Any help ?
Greatly appreciated!
the jquery:
Code:
$(document).ready(function() {
var $topLinks2 = $('#tab-nav-2 > ul > li > a');
var $topLinksbio = $('#tab-nav-2 > ul > li > ul > li');
$topLinks2.click(function() {
var $parentItem = $(this).parent(),
slideAmt = $(this).next().width(),
direction;
$topLinks2.removeClass('expanded');
$topLinksbio.hide();
if (parseInt($parentItem.css('marginLeft'), 10) > 0) {
direction = '-=';
} else {
$(this).addClass('expanded');
$topLinksbio.show();
direction = '+=';
}
$parentItem
.animate({marginLeft: direction + slideAmt}, 400)
.siblings()
.animate({marginLeft: '0'}, 300);
return false;
});
});
The css:
Code:
/* nav wrapper */
.container {
width: 610px;
margin: 40px auto;
text-align: left;
}
.tab-nav {
width: 610px;
overflow: hidden;
background: #ddd url(tab-slide.png) no-repeat 0 0;
}
.tab-nav ul {
position: relative;
float: left;
width: 1600px;
margin-right: 535px;
padding-left: 0;
list-style-type: none;
background-color: #fff;
}
.tab-nav li {
float: left;
clear: left;
}
.tab-nav a {
display: block;
width: 200px;
border-right: 1px solid #ddd;
height: 25px;
line-height: 24px;
float: left;
text-align: center;
text-decoration: none;
color: #000;
background: url(tab-slide.png) no-repeat 2px -194px;
}
.tab-nav a.expanded {
background-position: 2px -244px;
}
/* second level */
.tab-nav ul ul { float: left; background-color: #333; width: auto; margin-left: 0;}
.tab-nav li li {clear: none;}
.tab-nav li li a { color: #fff; width: 100px; background-image: none;}
The html:
Code:
<div id="tab-nav-2" class="tab-nav">
<ul>
<li>
<a href="#">Person 1</a>
<ul>
<li><a href="#">Biography</a></li>
</ul>
</li>
<li>
<a href="#">Person 2</a>
<ul>
<li><a href="#">Biography</a></li>
</ul>
</li>
<li>
<a href="#">Person 3</a>
<ul>
<li><a href="#">Biography</a></li>
</ul>
</li>
<li>
<a href="#">Person 4</a>
<ul>
<li><a href="#">Biography</a></li>
</ul>
</li>
<li>
<a href="#">Person 5</a>
<ul>
<li><a href="#">Biography</a></li>
</ul>
</li>
</ul>
</div>