Несколько функций jquery не работают

Я целый день пытался понять, почему мой код не работает. У меня есть несколько функций в jQuery, и когда я пытаюсь объединить их, одна из них не будет работать.

Это весь мой код на данный момент.

        jQuery(document).ready(function($){
        jQuery('#slider').anythingSlider({
            mode                : 'h',   // fade mode - new in v1.8!
            easing              : '<?php echo $data['slideshow_transition']; ?>',
            buildArrows         : <?php echo $data['slide_arrows']; ?>,      // If true, builds the forwards and backwards buttons 
            buildNavigation     : <?php echo $data['slide_anchor']; ?>,      // If true, builds a list of anchor links to link to each panel 
            buildStartStop      : <?php echo $data['slide_startstop']; ?>,      // If true, builds the start/stop button 
            toggleArrows        : <?php echo $data['slide_toggle_arrows']; ?>,     // If true, side navigation arrows will slide out on hovering & hide @ other times 
            toggleControls      : <?php echo $data['slide_toggle_controls']; ?>,     // if true, slide in controls (navigation + play/stop button) on hover and slide change, hide @ other times 
            startPanel          : <?php echo $data['slideshow_start_from']; ?>,
            autoPlay            : <?php echo $data['slideshow_pause']; ?>,     // If true, the slideshow will start running; replaces "startStopped" option 
            autoPlayLocked      : <?php echo $data['slideshow_user_pause']; ?>,     // If true, user changing slides will not stop the slideshow 
            autoPlayDelayed     : false,     // If true, starting a slideshow will delay advancing slides; if false, the slider will immediately advance to the next slide when slideshow starts 
            pauseOnHover        : <?php echo $data['slideshow_hover_pause']; ?>,      // If true & the slideshow is active, the slideshow will pause on hover 
            stopAtEnd           : <?php echo $data['slideshow_endstop']; ?>,     // If true & the slideshow is active, the slideshow will stop on the last page. This also stops the rewind effect when infiniteSlides is false. 
            playRtl             : <?php echo $data['slideshow_direction']; ?>,     // If true, the slideshow will move right-to-left 
            resumeOnVideoEnd    : true,      // If true & the slideshow is active & a supported video is playing, it will pause the autoplay until the video is complete 
            addWmodeToObject    : "opaque",
            onSlideBegin: function(e,slider) {
                // keep the current navigation tab in view
                slider.navWindow( slider.targetPage );
            }
        });
        // Videos on click grid and list style
        var animateSpeed = 500; 
        jQuery("#layout-controls a").click(function(){
            var curClass = jQuery('#videos').attr('class');
            var newClass = jQuery(this).attr('class');
            jQuery('#videos').fadeOut(animateSpeed,function(){
                jQuery('#videos').removeClass(curClass,animateSpeed);
                jQuery('#videos').addClass(newClass,animateSpeed);          
            }).fadeIn(animateSpeed);                        
            return false;       
        });
        jQuery("#cw-layout-controls a").click(function(){
            var curClass = jQuery('#cw-videos').attr('class');
            var newClass = jQuery(this).attr('class');
            jQuery('#cw-videos').fadeOut(animateSpeed,function(){
                jQuery('#cw-videos').removeClass(curClass,animateSpeed);
                jQuery('#cw-videos').addClass(newClass,animateSpeed);           
            }).fadeIn(animateSpeed);                        
            return false;       
        });
        //Validate contact form
        jQuery('#contactform').validate();
        //Slow scroll to comments area
        var commentTopPosition = jQuery('#comments').offset().top;
        // When #comment-scroll is clicked
        jQuery('#comment-scroll').click(function(){
            // Scroll down to 'commentTopPosition'
            jQuery('html, body').animate({scrollTop:commentTopPosition}, 'slow');
            // Stop the link from acting like a normal anchor link
            return false;
        });
        jQuery(".vf-table tr:even").addClass("even");
        jQuery(".vf-table tr td").css({'border-left': '1px solid <?php $borders ?>', 'border-right': '1px solid <?php $borders ?>'});
        jQuery(".vf-table tr th").css({'background': '<?php $borders ?>'});
    });

В начале кода есть anylingslider, который я использую в своей новейшей теме, в конце кода - код jquery для добавления стиля css к моей таблице в темах.

Код для изменения стиля таблицы, который я использовал ранее в разных темах и в другом файле js. Но по некоторым причинам это не будет работать в этом. Когда я заставляю границы таблиц работать, что-либо не работает, если я заставляю работать что-либо, другие коды не работают.

Я пытался создать файл.js для каждого кода отдельно и включить его в тему, я пытался включить код из файла php, я пытался включить код непосредственно в заголовок, я пытался добавить jquery без конфликта, вместо этого я пытался $ jQuery и ничего из этого не работает. Из этого я не вижу никаких ошибок в моем коде. Может кто-нибудь умнее объяснить мне, что я пропускаю, так что мой код не работает в этом.

1 ответ

Хорошо, я нашел, где проблема.

На страницах, где комментарии отключены, нет #comments div, поэтому здесь

var commentTopPosition = jQuery('#comments').offset().top;

JQuery перерывы.

и все после этого ломается. Я только что сделал небольшие изменения в своем PHP-файле комментариев, и теперь он работает.

Другие вопросы по тегам