In the following code:
span 1 has class "a"
span 2 has class "b c"
Clicking span 2 alerts: "b c" - good.
Then click span 1 to remove class "c" from span 2 - good,
Click span 2 again and it alerts: "b" - good..
If it no longer has class "c" then why did it still alert? Only class "c" was given instructions to alert..
The instruction was to add the alert to everything having class 'c'. There is no instruction there to remove the alert when you remove the class and so the alert is still there even though the class is not.
You could visualise it like this - imagine each span to be a block of wood, with class 'c' being indicated by a sticker attached to the wood. If we now imagine the alert as being a nail hammered into the wood. Removing the sticker does not remove the nail.
Ok, I see what you're saying. But when there's css attached to class "c", removing class "c" takes the css with it. Why is it any different for an alert? And how do I go about removing the alert function?