вот тебе часть рулона
<script>
function handler(e){
div1=document.createElement('div')
div1.appendChild(this)
document.body.appendChild(div1)
//this.parentNode.removeChild(this)
}
function handler2(e){
alert('2')
}
function addNewButts1() {
var i=1;
while (i<=5) {
createNewButt1(i);
i++;
}
}
function addNewButts2() {
var i=1;
while (i<=5) {
createNewButt2(i);
i++;
}
}
function createNewButt1(i) {
var parent = document.getElementsByTagName('body')[0];
var newButt1 = document.createElement('input');
newButt1.type = 'button';
newButt1.value = 'Change Button';
newButt1.id = 'butt1'+i;
parent.appendChild(newButt1);
}
function createNewButt2(j) {
var parent = document.getElementsByTagName('body')[0];
var newButt2 = document.createElement('input');
newButt2.type = 'button';
newButt2.value = 'Wrap Button';
newButt2.id = 'butt2'+j;
parent.appendChild(newButt2);
}
addNewButts1()
addNewButts2()
reg1=/butt1/
reg2=/butt2/
inputs=document.getElementsByTagName('input')
eventType = document.addEventListener ? ["addEventListener", ""] : ["attachEvent", "on"];
for(k=0;k<inputs.length;k++){
if(reg2.test(inputs[k].getAttribute('id'))){
//inputs[k].addEventListener('click',handler,false)
inputs[k][ eventType[ 0 ] ]( eventType[ 1 ] + "click", function( e ){
e = e || window.event;
handler.call( e.target || e.srcElement, e );
}, false );
}else{
inputs[k][ eventType[ 0 ] ]( eventType[ 1 ] + "click", function( e ){
e = e || window.event;
handler2.call( e.target || e.srcElement, e );
}, false );
}
}
</script>
.Не могу удалить кнопку