This can just be <code>$(event.target).toggleClass("flagged")</code>