I have a series of p tags that I want to have toggle in jQuery. I have an image slightly outside the p tags. When I write the toggle function and execute it, the animation toggles both the declared p tag and the image that is outside of the p tag.
Here is a fiddle:
Here is the code:
HTML
<div class="toggle" id="toggleIt"><a>CLICK ME</a></div>
<div class="nav">
<div class="One">
<img src="pipeline/img/right.png" class="imgFunc">
<p class="hideMe">Suspendisse cursus dapibus luctus knowing.
<br />
<span>website.com</span></p>
</div>
<!-- -->
<div class="nav">
<div class="One">
<img src="pipeline/img/right.png" class="directionalImg">
<p class="hideMe">Suspendisse cursus dapibus luctus knowing.
<br />
<span>website.com</span></p>
</div>
CSS
.directionalImg{
position: absolute;
padding-right: 10px;
margin-left: 10px;
}
.One{
margin-top: 125px;
}
.One p{
font-size: 9pt;
margin-left: 22px;
}
.One p span{
font-style: italic;
color: #999;
padding-right: 10px;
}
.toggleIt{
margin-top: 98px;
position: absolute;
font-size: 20pt;
}
</p>
jQuery
$("#toggleIt").click(function() {
$(".hideMe").toggle(500);
$("#toggleIt").animate({
"left": "400px"
}, 0);
$(".nav").animate({
"left": "400px"
}, 0);
});
Any thoughts on what might be causing this? Is it because my image is 'absolute' ? I tried writing the function as p.hideMe instead of just .hideMe and nothing happens. Any help is greatly appreciated.
EDIT: Sorry I was writing this quickly and forgot to close tags and place a '.' in front of hideMe. I wasn't copying and pasting over so I assure you all tags are closed in the actual document.