I have a website which has a div that I'm using as a list header (closed through the use of jQuery and HTML code). In other words, if someone clicks this "div" it will display a new "child div" which then has a sub-list button.
My problem stems from this, though each jQuery function runs independently perfectly fine, when situating them in a parent/child relationship things get a bit odd.
When the Parent "div" is open it works fine, however when the child sub-list button is pressed it displays the child's hidden "div" but also closes the previous displayed parent "div" leaving me with an 'open' "child" but a closed "parent".
If I open the "parent div" again the "child div" is already open, again pressing the "child div" button to close the "child div" closes both the parent and child.
This is an example of my html
<div class="dropdown" href="javascript:void(0);">
<h3><a>TITLE</a></h3>
<div class="Big2" style="display: none;">
<div class="twocolumn">
<div class="column facLeft">
<a class="acBtn" href="javascript:void(0);">Read More</a>
<div class="acBody" style="display: none;">
<!-- insert text etc -->
And this is my jQuery code that I use [placed in the head using script tags:]
$(function(){
$('.dropdown').click(function(){
if( $(this).hasClass('ake')){
$(this).closest('.dropdown').find('.Big2').stop().slideUp(200,'swing');
$(this).removeClass('ake');
}
else{
$(this).closest('.dropdown').find('.Big2').stop().slideDown(100,'swing');
$(this).addClass('ake');
}
});
});
and this one to call the "child"
$(function(){
$('.acBtn').click(function(){
if( $(this).hasClass('open')){
$(this).closest('.column').find('.acBody').stop().slideUp(200,'swing');
$(this).removeClass('open');
}
else{
$(this).closest('.column').find('.acBody').stop().slideDown(100,'swing');
$(this).addClass('open');
}
});
});
disregarding the fact that I'm using two codes separately instead of merging them into one (plus calling them in html) what could possibly be causing the second code to affect the first one? Is it something with .closest not stopping in the DOM tree?