【问题标题】:Anchor links need two clicks to go to the right section锚链接需要单击两次才能转到右侧部分
【发布时间】:2021-07-07 12:11:50
【问题描述】:

所以我有一个目录部分,我想在悬停过程中打开和关闭它。问题是我需要单击该目录中的链接两次才能使其转到正确的部分。锚标签中所有对应的ID都可以。这是一个wordpress网站。浏览器 Chrome。

可能是脚本有干扰,我该如何纠正?

这是我使用的 javascript:

(function( $ ) {
    $( '.tableofcontents' ).hover(function() {
        $( this ).children( 'h5' ).trigger( 'click' );
     });
})( jQuery ); 

【问题讨论】:

    标签: javascript wordpress tags anchor


    【解决方案1】:

    尝试将“hover”功能改为“mouseenter”

    $( '.tableofcontents' ).on('mouseenter', function() {
        $( this ).children( 'h5' ).trigger( 'click' );
    });

    【讨论】:

    • 或者鼠标悬停,也许
    • 非常感谢您的回答!我已经更换了它,但我有同样的问题。也许这不是脚本问题?不知道
    猜你喜欢
    • 2021-07-12
    • 1970-01-01
    • 2021-10-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-11-16
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多