каждому объекту по toggle-у
<script>
Object.prototype.toggle = function () {
var args = arguments;
var length = args.length;
var counter = this.counter;
this.addEventListener("click", function () {
if ( !counter || counter == length ) counter = 0;
args[counter++]();
});
}
document.addEventListener("DOMContentLoaded", function () {
var images = document.querySelectorAll(".visible img");
Array.prototype.map.call(images, function (img) {
img.toggle(
function () {
img.src = 'http://javascript.ru/forum/images/smilies/dance3.gif';
img.title = '111'
},
function () {
img.src = 'http://javascript.ru/forum/images/smilies/write.gif';
img.title = '222';
},
function () {
img.src = 'http://javascript.ru/forum/images/smilies/victory.gif';
img.title = '333';
}
);
});
});
</script>
<body>
<span class="visible"><img src="http://javascript.ru/forum/images/smilies/victory.gif" title="333" /></span>
<span class="visible"><img src="http://javascript.ru/forum/images/smilies/victory.gif" title="333" /></span>
<span class="visible"><img src="http://javascript.ru/forum/images/smilies/victory.gif" title="333" /></span>
<span class="visible"><img src="http://javascript.ru/forum/images/smilies/victory.gif" title="333" /></span>
<span class="visible"><img src="http://javascript.ru/forum/images/smilies/victory.gif" title="333" /></span>