Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #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.

    #484347

    Hey 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,
    Ismael

    #485362

    Ismael,

    Can I use jQuery also?

    #485365

    Hi!

    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,
    Yigit

    #485369

    Can I use this code on my custom nav? Thank you.
    Please see link provided.

    #485374

    Hi!

    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,
    Yigit

    #485394

    Thank 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.

    #485403

    Hi!

    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 8 years, 9 months ago by Yigit.
    #485420

    Thanks, 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 8 years, 9 months ago by avwebmaster.
    #485439

    It 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');
Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Current page change color of av icon’ is closed to new replies.