JavaScript函数阻止链接工作

时间:2014-11-18 14:28:30

标签: javascript jquery

此javascript函数用于为多个选择框设置动画,但是,我希望能够将这些选择框用作A HREF链接,但我相信此javascript中的某些内容阻止它充当href链接。

请有人帮我指出正确的方向

任何帮助非常感谢谢谢

(function() {

        var $container = $('#portfolio-items');

        if( $container.length ) {

            var $itemsFilter = $('#portfolio-items-filter'),
                mouseOver;

            // Copy categories to item classes
            $('article', $container).each(function(i) {
                var $this = $(this);
                $this.addClass( $this.attr('data-categories') );
            });

            // Run Isotope when all images are fully loaded
            $(window).on('load', function() {

                $container.isotope({
                    itemSelector : 'article',
                    layoutMode   : 'fitRows'
                });

            });

            // Filter projects
            $itemsFilter.on('click', 'a', function(e) {
                var $this         = $(this),
                    currentOption = $this.attr('data-categories');

                $itemsFilter.find('a').removeClass('active');
                $this.addClass('active');

                if( currentOption ) {
                    if( currentOption !== '*' ) currentOption = currentOption.replace(currentOption, '.' + currentOption)
                    $container.isotope({ filter : currentOption });
                }

                e.preventDefault();
            });

            $itemsFilter.find('a').first().addClass('active');
            $itemsFilter.find('a').not('.active').hide();

            // On mouseover (hover)
            $itemsFilter.on('mouseenter', function() {
                var $this = $(this);

                clearTimeout( mouseOver );

                // Wait 100ms before animating to prevent unnecessary flickering
                mouseOver = setTimeout( function() {
                    if( $(window).width() >= 960 )
                        $this.find('li a').stop(true, true).slideHorzShow(300);
                }, 100);
            }).on('mouseleave', function() {
                clearTimeout( mouseOver );

                if( $(window).width() >= 960 )
                    $(this).find('li a').not('.active').stop(true, true).slideHorzHide(150);
            });

        }

    })();

1 个答案:

答案 0 :(得分:1)

只需删除:

e.preventDefault();