F
F
fenucss2015-10-05 11:53:03
JavaScript
fenucss, 2015-10-05 11:53:03

How to add js script?

Code start:

window.onload=function(){
document.querySelector("input").oninput = function(){

If you connect the script directly, then everything works. If you connect through an external file, then the script does not work. What could be the problem? In window.onload?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
amatory10, 2015-10-05
@fenucss

the problem is not from window, try this:

document.querySelector('input').addEventListener("input", myFunc);
function myFunc() {
    // code here
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question