A little govnokoda - and voila!
<div class="one"> <div onclick="alert(this.innerHTML);">Кролик_1</div> <div onclick="alert('2');">Кролик_2</div> </div> <script> function dunno(cname, type){ var all = document.getElementsByTagName('*'); var classEls = []; for(var i = 0, il = all.length; i < il; ++i){ if(all[i].className.indexOf(cname)+1){ classEls[classEls.length] = all[i]; } } for(var i = 0, il = classEls.length; i < il; ++i){ all = classEls[i].getElementsByTagName('*'); for(var j = 0, jl = all.length; j < jl; ++j){ var todo = all[j].getAttribute('on'+type); if(todo){ var f = new Function(todo); f.apply(all[j]); } } } } dunno('one', 'click'); </script>
Yes, for the future: a class in javascript is not what you mean. Google
And not everyone can understand what “triggered elements” means either. Think how to explain in professional or more obvious terms.
JQuery
or can you use it? - Nicolas Chabanovsky ♦