可能重复:
$(document).ready 速记
有人可以帮我理解下面的JS代码吗,请:
$(function(){ <-- Is this a JS constructor? Why we need this?
var someVariable = $(".classa").on('click', function() { <-- At what point in time does someVariable get populated?
var $this = $(this);
id = $this.attr('id');
someVariable.removeClass('selected');
});
var someVariable2 = $(".classb").on('click', function() {
var $this = $(this);
id = $this.attr('id');
someVariable2.removeClass('selected');
});
});