I used different jQuery plugins and in some cases they were not working properly (or not working at all) until I embedded them into $(function({ ... })).
As example the plugin:
$('#DateTextBox').datetimepicker();
does not work, even if in the plugin web site it is used exactly in the same form.
Placing it inside $(function()) it turns working perfectly:
$(function ()
{
$('#DateTextBox').datepicker();
});
What the statement “$(function ())” brings exactly?
I tried to search in the same jQuery web site but I did not find an answer.
It makes sure your code will not get executed before the page has finished loading. It is a shorthand for
Read: http://api.jquery.com/ready/