jquery - External link open accordion -
i see lots of examples still don't !
try open accordion panel on page.
my goal:
when click on specific link on page a, redirected inside accordion data-id='32' on page b.
my working url:www.mysite.ccc/page/?sub=32#milmedia
url redirect id 32 not opening id 32.
<ul class="accordion"> <li class="accordion__item"><div class="underline-list__item js-accordion-open" data-id="30"><div class="underline-list__link"> <div class="underline-list__text"><h3>title</h3><span class="accordion_button"><span class="accordion_button_icon"></span></span></div></div></div> <div class="accordion__content js-accordion-content"><div class="wysiwyg"> content </div></div></li> <li class="accordion__item"><div class="underline-list__item js-accordion-open" data-id="32"><div class="underline-list__link"> <div class="underline-list__text"><h3 id="milmedia">title</h3><span class="accordion_button"><span class="accordion_button_icon"></span></span> </div></div></div> <div class="accordion__content js-accordion-content"><div class="wysiwyg"> content </div></div></li> <li class="accordion__item"><div class="underline-list__item js-accordion-open" data-id="42"><div class="underline-list__link"> <div class="underline-list__text"><h3>title</h3><span class="accordion_button"><span class="accordion_button_icon"></span></span></div></div></div> <div class="accordion__content js-accordion-content"><div class="wysiwyg"> content </div></div></li> </ul>
my jquery attempt:
jquery(document).ready(function($) { var check = location.hash; if (check == "milmedia") { $(window).load(function() { $('.js-accordion-open[data-id=32]').trigger('click'); }); } }); using version: <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> ** if that, it's working perfectly, "if" missing $(window).load(function() { $('.js-accordion-open[data-id=32]').trigger('click'); });
sorry bad english, i'm french ! in advance !
ok, found out !
$(function(){ if (window.location.hash == "#dfse") {$('.js-accordion-open[data-id=33]').trigger('click');} else if (window.location.hash == "#tyjh") {$('.js-accordion-open[data-id=32]').trigger('click');} else if (window.location.hash == "#ngfc") {$('.js-accordion-open[data-id=31]').trigger('click');} else {return false;} });
Comments
Post a Comment