Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/463.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
有人能解决我的Javascript格式问题吗?_Javascript_Syntax Error_Blogs - Fatal编程技术网

有人能解决我的Javascript格式问题吗?

有人能解决我的Javascript格式问题吗?,javascript,syntax-error,blogs,Javascript,Syntax Error,Blogs,下面是一个js,当我试图保存它时,它显示“元素的内容必须由格式良好的字符数据或标记组成。”错误,请帮助我解决这个问题 <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></scrip

下面是一个js,当我试图保存它时,它显示“元素的内容必须由格式良好的字符数据或标记组成。”错误,请帮助我解决这个问题

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/modernizr/2.6.2/modernizr.min.js"></script>
<script>
(function(){            

    if ($('html').hasClass('csstransforms3d')) {

        var foldingList = $('.folding'),
            foldingListHeight = $('.folding').height();
            topElemOffset = foldingList.offset().top,
   **===========================================^
    lint warning: multiple statements separated by commas (use semicolons?)**


            // Function responsible for unfolding the list
            unfold = function(){
                setTimeout(function(){
                    if (foldingList.hasClass('folded')){
                        foldingList.removeClass('folded');
                        return;
                    }
                }, 500);
            }

        // Fold/Unfold the list
        $('.connect').on("click",function(){

    **==^
    lint warning: missing semicolon**

            foldingList.toggleClass('folded');
        })
        // If needed, unfold the list right away
        if (topElemOffset <= $(window).height() - foldingListHeight)
            unfold();
    **===^
    lint warning: block statement without curly braces**


        // Check whether to unfold the list when scrolling/resizing
        $(window).on("scroll resize", function(){
            var th = $(this);               
            if (th.scrollTop() + th.height() - foldingListHeight  >=  topElemOffset)
                unfold();
**====^
    lint warning: block statement without curly braces**


        })
    }

})()
</script>

(函数(){
if($('html').hasClass('cstransforms3d')){
var foldingList=$('.folding'),
折叠列表高度=$('.folding').height();
topElemOffset=foldingList.offset().top,
**===========================================^
lint警告:多个用逗号分隔的语句(使用分号?)**
//负责展开列表的功能
展开=函数(){
setTimeout(函数(){
if(foldingList.hasClass('folded')){
removeClass(“折叠”);
返回;
}
}, 500);
}
//折叠/展开列表
$('.connect')。打开(“单击”,函数(){
**==^
lint警告:缺少分号**
foldingList.toggleClass('folded');
})
//如果需要,请立即展开列表
if(topelmofset=topelmofset)
展开();
**====^
lint警告:不带花括号的block语句**
})
}
})()

错误信息非常清楚

 topElemOffset = foldingList.offset().top; // ; instead of ,

 ...

 $('.connect').on("click",function(){
        foldingList.toggleClass('folded');
    }); // semicolon was mising

 ...
 //write if-statements like this
 if(expression){
     //dowork
 }

请添加到jsfiddle..注释不清楚?linting注释相当清楚。您想解决这些问题,还是“元素的内容必须由格式良好的字符数据或标记组成”错误,您没有提到它发生的位置/时间?