jQuery上的分号

时间:2012-05-15 15:26:29

标签: javascript jquery

以下jQuery在函数之后使用或不使用分号。为什么呢?

jQuery(document).ready(function(){
jQuery("#red").treeview({
    animated: "fast",
    collapsed: true,
    control: "#treecontrol",
    persist: "cookie"
})

});

适用于所有浏览器。这不会导致错误吗?

1 个答案:

答案 0 :(得分:12)

JavaScript实际上不需要分号。那只是惯例。

http://inimino.org/~inimino/blog/javascript_semicolons

我建议使用分号,就像我建议缩进代码一样。