首页 > 解决方案 > innerHTML 输入值

问题描述

以下代码将地图中的数据反映为 html 我想使用输入值中的信息 我该怎么做?


document.getElementById('location').innerHTML = place.formatted_address;
document.getElementById('lat').innerHTML = place.geometry.location.lat();
document.getElementById('lon').innerHTML = place.geometry.location.lng();


<ul id="geoData">
    <li>Location: <span id="location"></span></li>
    <li>Latitude: <span id="lat"></span></li>
    <li>Longitude: <span id="lon"></span></li>
</ul>

我想将这些代码作为输入值,但我做不到我的 javascript 知识有点糟糕

我尝试了这些代码,但没有

document.getElementById('location').value = place.formatted_address;
document.getElementById('lat').value = place.geometry.location.lat();
document.getElementById('lon').value = place.geometry.location.lng();

<input type="hidden" name="adres" id="location" value="">
<input type="hidden" name="lat" id="lat" value="">
<input type="hidden" name="lon" id="lon" value="">

标签: javascripthtml

解决方案


推荐阅读