I'm looking at a piece of code I did not write which contains:
jQuery(function($) {
$('#interaction').find('.item').hover(function() {
var $this = $(this);
$this.addClass('hover');
},
function() {
var $this = $(this);
$this.removeClass('hover');
})
.click(function() {
var $this = $(this);
var thisID = $this.attr('id');
//hide all visiable detail pages
resetpage($('.item-detail:visible'));
... etc.
Normally I would write my code to run inside of $(document).ready({ ... }); for example:
$(document).ready({
.click(function() {
var $this = $(this);
var thisID = $this.attr('id');
//hide all visiable detail pages
resetpage($('.item-detail:visible'));
... etc.
}
});
What is the difference (if any) between these two ways of writing the function or can I use them interchangeably?