I have utilized jQuery to create a simple show/hide functionality. Currently, I am facing two issues:
1) The hidden DIV is displaying over the footer instead of causing the footer to drop down automatically. How can I achieve this?
2) Is there a way to have the Contact Us DIV open when the page loads without using IDs?
Here is the link to my fiddle: http://jsfiddle.net/oampz/WkuMg/10/
HTML:
<ul class="outline">
<li>
<div class="heading"> <a>Contact Us</a>
</div>
<div class="content">
<ul>
<h1>Contact Us</h1>
<li>
<a href="">How to reach us</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">How to email us</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Contact Number</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
</ul>
</div>
</li>
<li>
<div class="heading">
<a>Products</a>
</div>
<div class="content">
<ul>
<h1>Products</h1>
<li>
<a href="">Tabels</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Ladders</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Chairs</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
</ul>
</div>
</li>
<li>
<div class="heading">
<a>Our Offices</a>
</div>
<div class="content">
<ul>
<h1>Our offices</h1>
<li>
<a href="">Bristol</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Manchester</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
<li>
<a href="">Leeds</a>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit.</p>
</li>
</ul>
</div>
</li>
</ul>
<div class="footer">Footer</div>
jQuery:
$(".heading").click(function () {
var $this = $(this);
$this.next(".content").show(400);
$this.parent().siblings().children().next().hide();
return false;
});
CSS:
.content {
display: none;
}
.outline {
position: relative;
}
.heading {
font-weight: bold;
padding: 15px 0 15px 20px;
background: GREY;
width: 30%;
}
.content {
width: 100%;
margin-left: 35%;
position: absolute;
top: -2px;
width: 60%;
overflow:hidden;
}
.footer {
width: 100%;
background: blue;
color: white;
}