2

对不起,我不是程序员。我正在为自己构建一个个人 WordPress 网站,我不得不编辑 php 文件,我遇到了这个问题。请有人帮我....

回答谢谢大家:D它的工作,有时我很惊讶我是多么愚蠢:P

萤火虫:

SyntaxError: missing } after function body
[Break On This Error]   

...){           var $container = $('#portfolio');               //load with opacity if fade i...

代码:

jQuery(document).ready(function ($) {
  var $container = $('#portfolio');
  //load with opacity if fade in is off
  if ($('#portfolio').attr('data-fade') != 1) {
    $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').css('opacity', 1);
  }
  //else show the loading gif
  else {
    $('.container.main-content').before('<span id="portfolio-loading"><span>');
  }
  $(window).load(function () {
    // initialize isotope
    $container.isotope({
      itemSelector: '.element',
      filter: '*',
      masonry: {
        columnWidth: $container.width() / <? php echo $cols; ?>
      }
    });
    //fade in
    if ($('#portfolio').attr('data-fade') == 1) {
      //fadeout the loading animation
      $('#portfolio-loading').stop(true, true).fadeOut(300);
      //fadeIn items one by one
      $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').css('opacity', 0);
      $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').each(function (i) {
        $(this).delay(i * 150).animate({
          'opacity': 1
        }, 350);
      });
    }
  });
4

4 回答 4

3

放在});代码的末尾

于 2013-05-23T03:00:29.973 回答
3

最后再添加一个});以关闭jQuery(document).ready(function ($) {

于 2013-05-23T02:59:08.420 回答
0

请参阅下面的评论:

jQuery(document).ready(function ($) {
    var $container = $('#portfolio');
    //load with opacity if fade in is off
    if ($('#portfolio').attr('data-fade') != 1) {
        $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').css('opacity', 1);
    }
    //else show the loading gif
    else {
        $('.container.main-content').before('<span id="portfolio-loading"><span>');
    }
}); //---> You were  missing this
$(window).load(function () {
    // initialize isotope
    $container.isotope({
        itemSelector: '.element',
        filter: '*',
        masonry: {
            columnWidth: $container.width() / '<? php echo $cols; ?>' //--> I am no expert in PHP but I think you need this inside single quotes
        }
    });
    //fade in
    if ($('#portfolio').attr('data-fade') == 1) {
        //fadeout the loading animation
        $('#portfolio-loading').stop(true, true).fadeOut(300);
        //fadeIn items one by one
        $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').css('opacity', 0);
        $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').each(function (i) {
            $(this).delay(i * 150).animate({
                'opacity': 1
            }, 350);
        });
    }
});
于 2013-05-23T03:03:53.127 回答
0
jQuery(document).ready(function ($) {
    var $container = $('#portfolio');
    //load with opacity if fade in is off
    if ($('#portfolio').attr('data-fade') != 1) {
        $('#portfolio.portfolio-items .col.span').css('opacity', 1);
    }
    //else show the loading gif
    else {
        $('.container.main-content').before('<span id="portfolio-loading"><span>');
    }

    $(window).load(function () {

        // initialize isotope
        $container.isotope({
            itemSelector: '.element',
            filter: '*',
            masonry: {
                columnWidth: $container.width()
            }
        });

        //fade in
        if ($('#portfolio').attr('data-fade') == 1) {

            //fadeout the loading animation
            $('#portfolio-loading').stop(true, true).fadeOut(300);

            //fadeIn items one by one
            $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').css('opacity', 0);

            $('#portfolio.portfolio-items .col.span_<?php echo $span_num; ?>').each(function (i) {
                $(this).delay(i * 150).animate({
                    'opacity': 1
                }, 350);
            });
        }
    });
});

固定的。

于 2013-05-23T03:04:03.387 回答