Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author malihu

    (@malihu)

    Hi,

    It seems that you didn’t add the custom script that exists in https://silent.se/psych/denial-acting-out-contempt-revenge/ and is necessary for the addition of the mPS2id-target-clicked class on the target.

    You can add the code below in your theme/child-theme functions.php:

    function ps2id_custom_script(){
        wp_register_script( 'ps2id-custom-script', '', array('jquery', 'page-scroll-to-id-plugin-script'), '', true );
        wp_enqueue_script( 'ps2id-custom-script' );
        wp_add_inline_script( 'ps2id-custom-script', '(function($){
            $(function(){
                $("body").on("click","._mPS2id-h",function(){
                var $this=$(this),
                    $href=$this.attr("href"),
                    $idx=$href.indexOf("#");
                if($idx !== -1){
                    $(".mPS2id-target-clicked").removeClass("mPS2id-target-clicked");
                    var $hash=$href.substring($idx + 1);
                    $("#"+$hash).addClass("mPS2id-target-clicked");
                }
                });
                $(document).on("click",function(){
                    var actvTarget=$(".mPS2id-target.mPS2id-target-clicked");
                    if(actvTarget.length) actvTarget.removeClass("mPS2id-target-clicked");
                });
            });
        })(jQuery);');
    }
    add_action( 'wp_enqueue_scripts', 'ps2id_custom_script' );

    Let me know

    Thread Starter Sridhar Katakam

    (@srikat)

    Thank you, that did it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘mPS2id-target-clicked class not getting added’ is closed to new replies.