简体   繁体   中英

Semicolon on jQuery

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?

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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