I have this simple piece of code in jQuery
$(document).ready(function() {
$('#switcher').click(function(event) {
if ($(event.target).is('.button')) {
$('body').removeClass();
if (event.target.id == 'switcher-narrow') {
$('body').addClass('narrow');
}
$('#switcher .button').removeClass('selected');
$(event.target).addClass('selected');
}
});
});
for this html code :
<body>
<div id="switcher" >
<h3>Style Switcher</h3>
<div class="button selected" id="switcher-default">
Default
</div>
<div class="button" id="switcher-narrow">
Narrow Column
</div>
</body>
I have a very simple, yet tricky question (at least for me) : what does body refer to ?
I imagine that it encapsulates everything under #switcher but then my h3 style would disappear on click.
It refers to the element
<body>.