There is no need of an array, you can use the element selector along with has attribute selector to get all image elements with the given attribute, then use .click() to register the event handler
$("img[attribute]").click(function(){
//do your stuff
})