Reputation: 327
So I have 2 different toggles, when you click on 'info 1' and then click 'link 1' (this would make it go to another page of the site) I want this to trigger toggle 'info 2' to open up for more info, but I can't figure this out..
(in this example i added both toggles on the same page but originally should be separate)
http://jsfiddle.net/qef9zvt4/2/
html:
SECTION 1
<ul class="accordion-media-types">
<li>
<a href="">Info 1</a>
<div class="hidden-content">
content
<ul>
<li>
<a href="">link 1</a>
</li>
</ul>
</div>
</li>
SECTION 2
<!-- THIS WOULD BE IN A DIFFERENT PAGE -->
<ul class="accordionListing">
<li>
<div class="accordion-heading">
<a href="">Info 2</a>
</div>
<div class="accordion-info section_22">
content
</div>
</li>
js:
//SECTION 1
$(document).on('click', '.accordion-media-types > li > a', function (e) {
e.preventDefault();
$(this).closest('li').toggleClass('active').find('.hidden-content').slideToggle(500);
});
//SECTION 2
$(document).on('click', '.accordionListing > li > div > a', function (e) {
e.preventDefault();
$(this).closest('li').toggleClass('active').find('.accordion-info').slideToggle(500);
});
Upvotes: 1
Views: 293
Reputation: 488
What are you exactly trying to do? Open the second div when you click the link?
Look at this fiddle: http://jsfiddle.net/qef9zvt4/9/
You can just add
$(document).on('click', '.accordion-media-types > li > div > ul > li > a', function (e) {
$(".accordionListing > li > div > a").trigger("click");
});
If it was in another page, can't you use document.ready to open the div? Or does it need to open only when on the first page, the link is clicked?
Upvotes: 1