- This topic has 5 replies, 2 voices, and was last updated 3 years, 4 months ago by
David.
-
AuthorPosts
-
December 12, 2022 at 9:08 am #2459297
Peter
Hi,
i use a hook to put some JS on it – this works realy fine. But now i will make a litte function this didn’t work. I am not sure if i make somethink wrong with the hook now.Hook:
<script> jQuery(document ).ready(function ($) { $('.link').on('click', function (e) { e.preventDefault(); var id = $(e.target).attr('id'); $('.tabref').hide(); $('#' + id + '-tabdetail').show(); }); }); </script>What will i do:
when i click the href with id=”one” then the div with id=”one-tabdetail” will show all other div with class “tabref” close.
The hide function work but i didn’t get the id from the href.
an example is here: https://jsfiddle.net/G8jK2/1/My settings at the hook: wp_footer – show only at the page what i need.
Is this my fault how to make the js in generatepress or a js failure?December 12, 2022 at 9:58 am #2459369David
StaffCustomer SupportHi there,
GeneratePress or its Hook don’t interfere with how Javascript works. So if its not working then its an issue with the Javascript.
First place to check is in the Browser Developer Tools > Console tab ( Right Click > Inspect the page to open in browser ). See if there are any errors showing before or after you click.Or share a link to the page on your site where i can see this and i can take a look.
December 12, 2022 at 10:35 am #2459434Peter
Hi there,
thanks for the fast Answer – i solve the Errors. At the Moment the “hide” action work. But not the Show ID.
I Deleteted The Live Link because was test – i edit it when it is live.
Between the “JS BLOCK” is this feature – the Content is “dynamic”. Thanks a lot for Help
December 12, 2022 at 11:40 am #2459498David
StaffCustomer SupportI think your issue is because there are multiple elements using the same ID.
I found this method which uses Classes for the target element.https://stackoverflow.com/a/5018087
Maybe that is better solution ?
December 12, 2022 at 12:25 pm #2459559Peter
Your support is awesome!
I read a lot and found a lot of solutions – also now my first time that i need help – you make it!Great Template – Great Team – Great Support!!!
Solution: if you want to hide/show all divs simultaneously than you have to give all divs | if you want to hide/show one div at a time than you can do this with id
December 13, 2022 at 2:23 am #2460113David
StaffCustomer SupportGlad to be of help 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.