<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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
.valueproperty applies to form elements (inputs), not divs. The simplest way to get the contents of your div element is with.innerHTML: