Here is how to alert and also display an attribute / attr of an element. In this case we are outputting the 'title' attribute but you can substitute for your attribute of choice:-

Example of how to output the title attr of image

A beautiful landscape

The Alt 'attr' of the image (A beautiful landscape) is displayed below