To check if an element has an ID:

if ($(this).is('[id]') {
    // Has ID
    console.log('Has ID: ' + $(this).attr('id'));
} else {
    // Has no ID
    console.log('Has no ID.');
}
Published On: February 11, 2019Categories: jQuery