我想要的是保存 html 值,然后在单击名为 previous 的按钮时使用上一个函数显示它。
但是我忘记考虑的是它document.getElementById('id')
不返回值,它返回类似[object HTMLElement]的东西。
我如何获得 id 的值?
var namevalue1 = document.getElementById('name');
var imagetitlevalue1 = document.getElementById('imagetitle');
var locationvalue1=document.getElementById('location') ;
var similaritiesvalue1 = document.getElementById('similarities');
var typevalue1 = document.getElementById('type');
var costvalue1 = document.getElementById('cost');
var datevalue1 = document.getElementById('date');
var pictureidvalue1 = document.getElementById('pictureid');
function previous()
{
document.getElementById('name').innerHTML = namevalue1;
document.getElementById('location').innerHTML = locationvalue1;
document.getElementById('similarities').innerHTML = similaritiesvalue1;
document.getElementById('type').innerHTML = typevalue1;
document.getElementById('cost').innerHTML = costvalue1;
document.getElementById('date').innerHTML = datevalue1;
document.getElementById('pictureid').src = pictureidvalue1;
}