How can val() return Number?

javascript, jquery, numbers, string

Solution

Some HTML5 elements e.g. progress;

console.log(typeof $("#prog").val()); // number 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<progress value="50" max="100" id="prog"></progress>

Problem

In the `val`docs written this description: .val() Returns: String, Number, Array I tried to get a `Number`, but it seems to return `string` only, Is there something that I'm doing wrong? ``` $('#gdoron').val('1'); alert($('#gdoron').val() === '1'); // true alert(typeof $('#gdoron').val()); // string. $('#gdoron').val(1); alert($('#gdoron').val() === 1); // false alert(typeof $('#gdoron').val()); // string (not "number"!) ``` ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" id="gdoron" /> ``` My question is: how can `val()` return number as the docs says? The question is not about how can I parse the string. ​

Original source

Related problems