As someone new to Javascript
and JQuery
, I have looked at online tutorials and I have two datepickers working using the following HTML:
<head>
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>
$( function() {
$( "#sdate" ).datepicker();
$( "#edate" ).datepicker();
} );
</script>
</head>
My question is: why does there have to be an anonymous function which sets up the datepickers? What is the meaning of that code, and how does it get executed?