javascript - Semicolon on jQuery - Stack Overflow

The following jQuery works with or without a semicolon after the function. Why?jQuery(document).ready(f

The following jQuery works with or without a semicolon after the function. Why?

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

});

It works on all browsers. Wouldn't this cause an error?

The following jQuery works with or without a semicolon after the function. Why?

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

});

It works on all browsers. Wouldn't this cause an error?

Share Improve this question edited Jul 11, 2012 at 12:30 Undefined 11.4k5 gold badges39 silver badges62 bronze badges asked May 15, 2012 at 15:26 AlxVallejoAlxVallejo 3,2386 gold badges53 silver badges82 bronze badges 1
  • Why should it? Semicolons are optional (at least at this position). – Felix Kling Commented May 15, 2012 at 15:27
Add a ment  | 

1 Answer 1

Reset to default 13

JavaScript doesn't actually require semicolons. That's just convention.

http://inimino/~inimino/blog/javascript_semicolons

I remend using semicolons, just like I'd remend indenting your code.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1743627368a4480763.html

相关推荐

  • javascript - Semicolon on jQuery - Stack Overflow

    The following jQuery works with or without a semicolon after the function. Why?jQuery(document).ready(f

    19小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信