Try like
<script>
function Data(string)
{
$('.filter').removeClass('active');
$(this).parent('.filter').addClass('active') ;
}
</script>
For the class selector you need to use .
before the classname.And you need to add the class for the parent. Bec you are clicking on anchor tag not the filter
.