JSLint won't recognize getElementById

199 views Asked by At

JSLint gives errors with simple function, running on brackets with JSLint.

Javascript:

function soundSorry() {
    getElementById("player").play();
} 

Error codes:

2   Missing 'use strict' statement. getElementById("player").play();
2   'getElementById' was used before it was defined. getElementById("player").play();

Any ideas?

1

There are 1 answers

0
Tushar On BEST ANSWER

You missed document prefix. As getElementById is defined on document object you've to call it using document object as follow:

document.getElementById("player").play();
// ^^^^^^

Docs