Nicholas Nicholas - 1 year ago 91
Javascript Question

Javascript : What is the difference between $(function () {}); and function () {}

What is the difference between

$(function () {
/* some functionality */


function () {
/* some functionality */

I've seen the first one used to initialize bootstraps tooltip (for eg.) but I tried the same with the second function it doesn't work. Can someone help me out please?

Answer Source

The first one, in jquery, is a shorthand for $(document).ready(function(){}).

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download