O
O
olya_0972018-03-04 00:21:39
JavaScript
olya_097, 2018-03-04 00:21:39

How can I write a string in func in a different way, that is, without this?

<ol>

<li>11</li>
<li>333</li>
</ol>

<script>

var elems=document.getElementsByTagName('li');
for(var i=0;i<elems.length;i++){
elems[i].addEventListener('click',func);
}
function func(){
this.parentElement.removeChild(this);
}


</script><code></code>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-03-04
@olya_097

function func(e) {
  e.target.parentElement.removeChild(e.target);
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question