For example, I need to have a list of all tags that have id attribute set (it could be any other attribute, id is just an example).
id
Try this:
document.querySelectorAll('[id]')