简体   繁体   English

SyntaxError:missing; 在声明之前 - jQuery ContentHover

[英]SyntaxError: missing ; before statement - jQuery ContentHover

Getting the error on console, says something is wrong with this code.. 在控制台上获取错误,说这个代码有问题。

$.fn.contenthover = function(method) {  
    if (methods[method]) {
        return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method) {
        return methods.init.apply(this, arguments);
    } else {
        $.error('Method '+ method +' does not exist in contentHover plugin.');
    }
});

And also this in HTML 而且这也是HTML

<script>
$(document).ready(function(){
    $('#d1').contenthover({
        overlay_background:'#000',
        overlay_opacity:0.5
    });
});
</script>

Could someone tell me where I went wrong with both? 有人能告诉我哪里出错了吗? Thanks! 谢谢! - stilllearning - 还在学习

     $.fn.contenthover = function(method) {  
if (methods[method]) {
    return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
    return methods.init.apply(this, arguments);
} else {
    $.error('Method '+ method +' does not exist in contentHover plugin.');
} 
}         

Please Remove this "):" characters from the function. 请删除此“):”函数中的字符。

The issue to me looks like a trailing parentheses at the end. 对我来说这个问题看起来像是最后的尾随括号。 Try this: 尝试这个:

$.fn.contenthover = function(method) {  
    if (methods[method]) {
        return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method) {
        return methods.init.apply(this, arguments);
    } else {
        $.error('Method '+ method +' does not exist in contentHover plugin.');
    }
};

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM