Set variable name to clicked element name

How can I set a variables value to the name of an element I click?
Thanks.

The simplest way would be…

var x = element.id

alert(x)