I'm familiar with codes with forms like this:
$(document).ready(function() {})
Or
(function(){})()
But I'm confused when I saw codes are like this
$(function () {
$(".modal-link").click(function (event) {
event.preventDefault()
$('#myModal').removeData("modal")
$('#myModal').modal({remote: $(this).attr("href")}).css({
'width': function () {
return ($(document).width() * .9) + 'px';
},
'margin-left': function () {
return -($(this).width() / 2);
}
});
})
})
It seems that $
is a jquery function, why should the function be wrapped in this function? Is is the same as $(document).ready(function() {})
?