简体   繁体   English

jQuery无法在Firefox和IE上运行,无法在链接单击时执行操作

[英]Jquery not working Firefox and IE for action executed on link click

I have a page that's functioning well on Chrome, but not on IE or Firefox. 我的网页在Chrome上运作良好,但在IE或Firefox上却无法正常运作。 I put together this Jsfiddle which shows part of the issue: https://fiddle.jshell.net/dkwsswdw/2/ 我将显示问题的一部分的Jsfiddle放在一起: https ://fiddle.jshell.net/dkwsswdw/2/

If you open it on Chrome, you should be able to click on the down arrow at the top of the window and scroll down from div to div. 如果您在Chrome上打开它,则应该可以点击窗口顶部的向下箭头,然后从div向下滚动到div。 If you open it in Firefox or IE, it stops working. 如果您在Firefox或IE中打开它,它将停止工作。

Any ideas? 有任何想法吗? I understand that there are issues with jQuery not getting called properly in FF and IE, but I'm not sure how it applies to this issue. 我了解到jQuery和FF和IE无法正确调用存在一些问题,但是我不确定它如何应用于此问题。 (I've looked at this extensively and I'm just too new to jQuery to figure out exactly how this applies.) (我已经对此进行了广泛的研究,但对于jQuery来说我还太陌生,无法确切地了解这是如何应用的。)

Note: 注意:

If it's helpful, here's the actual loop that I'm running in Wordpress to display the posts and add the 'current' class to the first post in the loop: 如果有帮助,这是我在Wordpress中运行的实际循环,以显示帖子并将“当前”类添加到循环的第一篇文章中:

<?php

        // The Arguments
        $args = array(
            'post_type' => 'strange',
            'posts_per_page' =>-1, 
            'order_by' => 'menu_order'

        );

        $c = 0; 
        $class = ''; 

        // The Query
        $the_query = new WP_Query( $args ); ?>

        <?php

        // If we have the posts...
        if ( $the_query->have_posts() ) : ?>

        <!-- Start the loop the loop --> 
            <?php while ( $the_query->have_posts() ) : $the_query->the_post(); 
            $c++; 
            if ( $c == 1 ) $class .= ' current'; // if the item is the first item, add class current
            else $class = ''; 
            ?>

                <div id="strange-container" class="strange-container <?php echo $class; ?>">    

                    <img src="<?php the_field('strange-img'); ?>" alt="<?php the_title(); ?>" />

                    <span><?php the_field('strange-text'); ?></span>

                </div>

            <?php endwhile; endif; ?>

        <?php wp_reset_postdata(); ?>

FYI, your images are are behind an htpasswd . 仅供参考,您的图片位于htpasswd后面。

That said, some browsers like to animate on body while others like to animate on html . 也就是说,有些浏览器喜欢在body上设置动画,而另一些喜欢在html上设置动画。 Change your line that looks like this: 更改如下所示的行:

$('body').animate({

to this: 对此:

$('html,body').animate({

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM