0

in past, we can get value like this way

<input type="text" id="num">
<script>
    var numEl = document.getElementById('num');
</script>

but now, we can get value like this way

<input type="text" id="num">
<script>
    var numEl = num.value;
</script>

Q. Since when can we be able to use this way? Q. Where can I search this way where like api?

swz
  • 63
  • 6
  • Neither the first nor second snippet would give you the value in any current or historical version of javascript. What you need is the combination of both, which has worked from the very first DOM API specification here: https://www.w3.org/TR/REC-DOM-Level-1/level-one-html.html#method-getElementById – coagmano Apr 23 '21 at 01:50
  • @FredStark The second does indeed return the value https://jsfiddle.net/3cwp2g6o/ – charlietfl Apr 23 '21 at 02:01

0 Answers0