All the solutions provided force you to know the element you will click beforehand. If you want to get the class from any element clicked you can use:
$(document).on('click', function(e) {
clicked_id = e.target.id;
clicked_class = $('#' + e.target.id).attr('class');
// do stuff with ids and classes
})