document.getElementById().value return undefined in chrome

javascript

Solution

The `.value` property applies to form elements (inputs), not divs. The simplest way to get the contents of your div element is with `.innerHTML`:

document.getElementById('hour').innerHTML;

Problem

``` <div id="hour" style="display: none">2</div> ``` JavaScript code: ``` <script type="text/javascript"> var _h = document.getElementById('hour').value alert(_h); </script> ``` Chrome returns `undefined`. What is the problem?

Original source

Related problems