PDA

View Full Version : Comparison with 0 and JSLint error



Rain Lover
07-11-2014, 07:40 AM
Here's the code:


<input type="number" value="0" id="input">
<script>
if (document.getElementById('input').value == 0) {
alert('Hello, world!');
}
</script>

DEMO (http://jsfiddle.net/Mori/9hwTb/)

And here's the JSLint error:


Expected '===' and instead saw '=='.

But when I listen to the advice and change == to ===, the alert stops appearing.

coothead
07-11-2014, 08:34 AM
Hi there Rain Lover,


JSLint requires...


if (document.getElementById('input').value === '0')


coothead