bes,
this
<script>
Object.prototype.toggle = function () {
var args = arguments;
var length = args.length;
var counter = 0;
this.addEventListener("click", function () {
if (counter == length ) counter = 0;
args[counter++].call(this);
});
}
document.addEventListener("DOMContentLoaded", function () {
var images = document.querySelectorAll(".visible img");
Array.prototype.map.call(images, function (img) {
img.toggle(
function () {
this.src = 'http://javascript.ru/forum/images/smilies/dance3.gif';
this.title = '111'
},
function () {
this.src = 'http://javascript.ru/forum/images/smilies/write.gif';
this.title = '222';
},
function () {
this.src = 'http://javascript.ru/forum/images/smilies/victory.gif';
this.title = '333';
}
);
});
});
</script>
<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>