我的错误?参数列表后面的Uncaught SyntaxError:missing)

时间:2015-08-28 13:41:40

标签: javascript jquery

简单的脚本,不确定错误的来源。想想我有我的眼罩!

<script type="text/javascript">
    var listingId = "<!-- TMPL_VAR listing_id -->";
    var photoCount = "<!-- TMPL_VAR photo_count -->";
    var photoNum = 1;
    for(i=photoNum; i<=photoCount; i++) {
        $('.carousel-inner').append('<div class="active item"><img src="/property/photo/' + listingId + '/' + i'" /><div class="carousel-caption"><!-- TMPL_VAR remarks_general --></div></div>');
    }
</script>

2 个答案:

答案 0 :(得分:1)

您在此行中缺少+

$('.carousel-inner').append('<div class="active item"><img src="/property/photo/' + listingId + '/' + i'" /><div class="carousel-caption"><!-- TMPL_VAR remarks_general --></div></div>');

试试这个

$('.carousel-inner').append('<div class="active item"><img src="/property/photo/' + listingId + '/' + i+'" /><div class="carousel-caption"><!-- TMPL_VAR remarks_general --></div></div>');

答案 1 :(得分:-1)

首先,我可以看到你在src属性的img标签上缺少+。在+

之后添加了i
var listingId = " TMPL_VAR listing_id";
    var photoCount = "<!-TMPL_VAR photo_count";
    var photoNum = 1;
    for(var i=photoNum; i<=photoCount; i++) {
        $('.carousel-inner').append('<div class="active item"><img src="/property/photo/' + listingId + '/' + i+'" /><div class="carousel-caption"><!-- TMPL_VAR remarks_general --></div></div>');
    }