jQuery 1.10.2如何修复Uncaught SyntaxError:意外的字符串

时间:2017-10-26 02:30:01

标签: jquery syntax-error

  

未捕获的SyntaxError:意外的字符串

我不知道如何在jQuery 1.10.2中调用函数。我做错了什么?

http://prntscr.com/h23m4j

http://prntscr.com/h23mp6

<div id="#slider" style="position: relative;">
    <div class="list" style="position: relative;overflow: hidden;height: 100%;">
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
        <div><img src="<?php echo $this->paths->get_photo_url_by_photo_object($photo, 'product_page_small_image')?>" alt=""></div>
    </div>
</div>
<!--suppress JSAnnotator -->
<script>
$(document).ready({
    $('#slider').simpleSlide.click(function ({
        column: 4,
        showButtonForever: true,
        cycle: false,
        autosliding: 0
    });
})
</script>

2 个答案:

答案 0 :(得分:0)

您正在尝试将JSON对象传递给$(document).ready()。根据{{​​3}},它将函数作为参数。

此外,您在simpleSlide点击处理程序中错过了一个类似的错误(缺少括号)。

因此,你应该修改你的代码:

$(document).ready(function() {
    $('#slider').simpleSlide.click(function() {
        column: 4,
        showButtonForever: true,
        cycle: false,
        autosliding: 0
    });
});

答案 1 :(得分:0)

我认为这里不需要使用.click()方法,除非您在单击容器时尝试生成幻灯片。关注the example you providedthe examples on the simpleSlider demo,我希望您的功能如下所示:

$(document).ready(function(){
   $('#slider').simpleSlide({
      column: 4,
      showButtonForever: true,
      cycle: false,
      autosliding: 0
   });
});

正如另一个答案中所述,$(document).ready()使用.click()$(function(){ $("#ets_gp_height").focus(function(){ if(!$(this).hasClass("minbox")) { } else { $(this).removeClass("minbox"); } }); }); 函数缺少括号时会出现一些语法错误。