$(document).ready( function () {
var table = $('#example').DataTable();
$('#example tbody').on('click', 'tr', function (event) {
console.log('td click event');
table.$('tr.selected').removeClass('selected');
$(this).addClass('selected');
event.stopPropagation();
});
$('body').on('click', function () {
console.log('body click event');
table.$('tr.selected').removeClass('selected');
});
} );