I cannot seem to remove the class 'foo' and I do not understand why. When the user clicks on .foo jQuery is suppose to remove .foo. At first glance it seems to work as the text is no longer red. However, clicking .foo several times will result in the alert box appearing thus meaning .foo has not completely been removed. I do not understand why this is happening.
jQuery:
$(document).ready(function() {
$('.foo').click(function() {
$(this).removeClass('foo');
alert('Class .foo should have been removed. Why is this alert still appearing?');
});
});
html:
<p class="foo">foo</p>
css:
.foo { color: red; }