简体   繁体   中英

jQuery Accordion plugin - SHOPIFY

I'm hoping someone can help to answer my question...

I am currently using an accordion on my Shopify site to display some pretty extensive content. You can see a demo of what I'm using here: http://www.snyderplace.com/demos/accordion.html

I'm wanting to be able to create a link on my webpage that will take the customer to, say the 3rd panel of the accordion OPEN, but I just can't figure out what JS I need to be using to do this! Can someone help! Please?

First thing that comes to my mind is passing aa meaningless # along with the link, like you would be going to a anchor. Then on page load check to see if the URL contains the hashtag, if true trigger the panel you want to open.

Link on initial page:

<a href="/newpag#panel-3" >link</a>

jQuery:

if(window.location.href.indexOf('#panel-3')){
   $('.thirdSection').trigger('click')}

I haven't tested this at all but with a bit of tweaking it should do the trick.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM