$(document).ready(function() {
$('#switcher-default').bind('click', function() {
$('body').removeClass('narrow');
$('body').removeClass('large');
});
});
the second function:
$(document).ready(function() {
$('#switcher-default').click(function() {
$('body').removeClass('narrow');
$('body').removeClass('large');
});
});
I am a newbie of jQuery, what’s the difference between the above code? I feel that add or remove the bind function, the result is the same.why the code adds the bind event?
They both will do the same thing attach
clickhandler to#switcher-defaultelement.bindis just other way of attaching any event to matched set of elements.Using
bindyou can attach multiple events with common event handler on the element. The eventType should be separated by a space.