【问题标题】:jquery is not working properly syntax errorjquery 无法正常工作语法错误
【发布时间】:2013-06-07 00:08:05
【问题描述】:

大家好,我正在使用 jquery 作为 wordpress 的灯箱效果弹出窗口。我在 Wamp Server 中尝试过工作正常(本地主机),但是今天只有我们没有从 jquery 得到任何输出我用 firebug 的控制台检查了它的 throws 语法错误我不确定我做错了什么我为你提供了你可以的代码查看它并告诉我我在哪里做错了。

<script type="text/javascript">



jQuery(document).ready(function($){

if(jQuery.cookie('popup_user_login')!='yes'){

<?php if ($_COOKIE['test']!='5') {?>

jQuery('#ptechsolfb').delay(<?php echo get_option('popup_template_delay');?>).fadeIn('medium');<?php 

   if(get_option('popup_delay_auto')=='1') { ?> function countDown(i) {

             var int = setInterval(function () {

           document.getElementById("ptechsolin").innerHTML =  "You Must Wait Until the Timer Ends " + i;



        i-- || clearInterval(int) || jQuery('#ptechsolfb').stop().fadeOut('medium') ; 

         //if i is 0, then stop the interval

    }, 1000);

}

countDown(<?php echo get_option('popup_template_count');?>);





<?php } ?> <?php if(get_option('close_esckey_ed')=='1') { ?>

     jQuery(document).bind('keydown', function(e) { 

        if (e.which == 27) {

            jQuery('#ptechsolfb').stop().fadeOut('medium')

        }

    });<?php }?><?php if(get_option('close_externel_click')=='1') {?>jQuery('#ptechsolfb').click(function(){jQuery('#ptechsolfb').stop().fadeOut('medium');<?php } ?><?php if(get_option('popup_template_close')=='1') {?> jQuery('#fbclose').click(function(){jQuery('#ptechsolfb').stop().fadeOut('medium');<?php }?><?php } ?>})     }jQuery.cookie('popup_user_login','yes',{path:'/',expires:<?php echo (get_option('popup_plugin_template_cookies')); ?>})

});
</script>

这是我在萤火虫控制台中看到的截图。

这就是 jQuery 无法正确加载的问题吗?任何建议将不胜感激。

这里是Working Site Example 谢谢, 维姬

 jQuery(document).ready(function($){

    if (jQuery.cookie('popup_user_login') != 'yes'){



    jQuery('#ptechsolfb').delay(100).fadeIn('medium');
            function countDown(i) {

            var int = setInterval(function () {

            document.getElementById("ptechsolin").innerHTML = "You Must Wait Until the Timer Ends " + i;
                    i-- || clearInterval(int) || jQuery('#ptechsolfb').stop().fadeOut('medium');
                    //if i is 0, then stop the interval

            }, 1000);
                    }

    countDown(25);
            jQuery(document).bind('keydown', function(e) {

    if (e.which == 27) {

    jQuery('#ptechsolfb').stop().fadeOut('medium');
    }

    });
            jQuery('#ptechsolfb').click(function(){jQuery('#ptechsolfb').stop().fadeOut('medium'); }); jQuery('#fbclose').click(function(){jQuery('#ptechsolfb').stop().fadeOut('medium'); });jQuery.cookie('popup_user_login', 'yes', {path:'/', expires:0})

    });
});

【问题讨论】:

  • 谢谢乔,我试过这是编辑过的东西我不确定这是我在使用 netbeans 时遇到的错误
  • 我也试过了 编辑器上的错误仍然出现
  • 我根据您的建议修改了最后一个代码
  • 看到你的答案是正确的,但我仍然收到 eof Unexpected error 的错误

标签: jquery jquery-plugins wordpress


【解决方案1】:

老兄,你真的错过了“});”。

第二行中打开的“{”的结束位置在哪里

jQuery(document).ready(function($){

干杯... :P

【讨论】:

  • 我也试过了 即使它在本地主机上不起作用,但它在现场工作 本地主机是 Wamp 服务器 现场是 Linux 是否会导致问题
  • 老兄平衡“}”有问题,你可以使用notepad++或任何其他受人尊敬的编辑器来跟踪它们。
猜你喜欢
  • 2015-11-13
  • 2011-07-24
  • 1970-01-01
  • 2014-04-08
  • 2021-06-16
  • 2015-12-14
  • 2015-11-13
  • 2012-07-03
相关资源
最近更新 更多