How can I toggleClass and remove class from all other elements? Consider a div that contains a tags: html:
I'm assuming that you have a class 'size' that contains a number of elements of which only one should be able to have the class 'checked' at any one time.
$(".size a").click(function()
{
if($this).hasClass('checked')
{
$(".size a").removeClass('checked');
$(this).addClass('checked');
}
else
{
$(this).removeClass('checked');
}
}