javascript - jQuery : missing ; before statement

标签 javascript jquery compiler-errors syntax-error

我根本不知道为什么会收到此错误(我读了每个具有类似名称的主题,但这些问题的答案均​​不适用):

$(document).ready(function() {

postAndFade($node, post_key) {
    var id = $node.parents.('.id').find('.id-value').text();
    var post_val = $node.text();
    $node.fadeOut('slow');

    $.ajax({
        type: "POST",
        url: "process.php",
        data: "id="+id+"&"+post_key+"="+post_val,
        success: function(data) {
            $node.html(data);
            $node.fadeIn('slow');           
        }
    });
    return false;
}

$('.featured-value').click(function() { return postAndFade($this, 'featured'); });
$('.visible-value').click(function() { return postAndFade($this, 'visible'); });

});

最佳答案

postAndFade($node, post_key) {

您缺少function关键字。
var id = $node.parents.('.id').find('.id-value').text();

.之后,您还有一个额外的parents

关于javascript - jQuery : missing ; before statement,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7663813/

相关文章:

javascript - 如何获得在警报 “cancel” 后返回 ID 的选项?

java - 无法导入 org.apache.commons

Java <identifier> 需要 writeObject()

c++ - 无法在Visual Studio中的Bash中运行文件

javascript - 使用each()循环div

javascript - 如何一键上传文件

javascript - "bbcode"脚本不工作

javascript - 网站在加载时跳转到中间内容。一页设计

javascript - 指定字体名称的一部分

jquery - 我无法检查父级是否已被删除