猿问

如何从 html 表单获取值到 javascript

价值是 null


html输入代码和javasript:


var tanggal1 =  document.getElementById("tanggal1").value;

var tanggal2 =  document.getElementById("tanggal2").value;

alert(tanggal1);

我期望的输出tanggal1 = <input type='date' name='tanggal1' id='tanggal1'/>值


泛舟湖上清波郎朗
浏览 231回答 2
2回答

人到中年有点甜

HTML:<input type="text" name="name" id="tanggal1" value="value" />JS:var tanggal1 = document.getElementById("tanggal1").value;

白板的微信

HTML:<!DOCTYPE html><html>&nbsp;<head>&nbsp; <title>Test</title></head><body onload="test();">&nbsp; &nbsp; <input type="text" name="name" id="tanggal1" value="value">&nbsp; &nbsp; <script>&nbsp; &nbsp; &nbsp; &nbsp; function test()&nbsp; &nbsp; &nbsp; &nbsp; {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;alert(document.getElementById('tanggal1').value);&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; </script></body></html>
随时随地看视频慕课网APP

相关分类

JavaScript
我要回答