-
AuthorPosts
-
August 6, 2015 at 3:50 pm #483967
<style type="text/css"> .current-av-icon-color {color:red !important;} </style> <script>// <![CDATA[ var icons = jQuery(".flex_column .av_font_icon"); icons.css("display", "inline-block").css("width", 120).css("height", 50).css("color", "#58585b"); icons.closest(".flex_column").css("text-align","center"); // ]]></script> <script>//<![CDATA[ jQuery(function() { jQuery('.av-icon-char').each(function() { if (jQuery(this).attr('href') === window.location.pathname) { jQuery(this).addClass('current-av-icon-color'); } }); }); //]]> </script>
Hi,
I`ve implemented this jQuery script to change the av icon when a user is on a current page.
Is it possible to achieve this? I’m not sure if the av icons are used as navigation menus for this theme.
Thank you.August 7, 2015 at 9:05 am #484347Hey avwebmaster!
Thank you for using Enfold.
You can use the wp_head or wp_footer hook to add the script. Something like the code provided here: https://kriesi.at/support/topic/plugin-event-manager-und-element-slide-show-volle-breite-rechte-spalte-bug/
Regards,
IsmaelAugust 10, 2015 at 3:07 pm #485362Ismael,
Can I use jQuery also?
August 10, 2015 at 3:09 pm #485365Hi!
Yes, you can add following code to Functions.php file in Appearance > Editor
function add_custom_target(){ ?> // Your code goes here <?php } add_action('wp_footer', 'add_custom_target');
Best regards,
YigitAugust 10, 2015 at 3:13 pm #485369Can I use this code on my custom nav? Thank you.
Please see link provided.August 10, 2015 at 3:17 pm #485374Hi!
Sure, you can use it and if your code is correct, it would work. But if not, please elaborate on the changes you would like to make, we may provide you an alternative solution
Best regards,
YigitAugust 10, 2015 at 3:41 pm #485394Thank you. How do I insert the jQuery code in the php script?
Should I start with<script> $(document).ready(function(event) { //jQuery goes here }): </script>
I also noticed the $ does not work in the code block.
August 10, 2015 at 3:49 pm #485403Hi!
Please add following code to Functions.php file in Appearance > Editor
function add_custom_target(){ ?> <script> $(document).ready(function(event) { //jQuery goes here }): </script> <?php } add_action('wp_footer', 'add_custom_target');
Regards,
Yigit- This reply was modified 9 years, 4 months ago by Yigit.
August 10, 2015 at 4:07 pm #485420Thanks, but I can add this to my child functions, correct?
function add_custom_target(){ ?> <script> $(document).ready(function(event) { $('explore-menu ul li a[href^="/' + location.pathname.split("/")[1] + '"]').addClass('active'); }); // end doc ready </script> <?php } add_action('wp_footer', 'add_custom_target');
Does not seem to work
- This reply was modified 9 years, 4 months ago by avwebmaster.
August 10, 2015 at 4:34 pm #485439It is working now – set active link on custom menu
function add_custom_target(){ ?> <script> jQuery(document).ready(function($) { jQuery("*").find("a[href='"+window.location.href+"']").each(function(){ jQuery(this).addClass("active"); }); }); // end doc ready </script> <?php } add_action('wp_footer', 'add_custom_target');
-
AuthorPosts
- The topic ‘Current page change color of av icon’ is closed to new replies.