K
K
kpa6uu2016-03-06 00:37:56
JavaScript
kpa6uu, 2016-03-06 00:37:56

How to remove the oninput property from an element?

Hello. How can you remove the oninput property from a normal element? I tried unbind, off - does not help. Thanks in advance!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis, 2016-03-06
@kpa6uu

<input type="text">
<button>Удалить обработчик события</button>

var inp = document.querySelector('input');
inp.oninput = function(){
  console.log(this.value);
};

document.querySelector('button').addEventListener('click', function(){
  inp.oninput = null;
}, false);
Sandbox example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question