function reset()
{
var message=confirm("你确定要重置所有设置么?");
if(message==true)
{
document.getElementById('txt').style.color = "black";
document.getElementById('txt').style.backgroundColor = "white";
document.getElementById('txt').style.width = orignWidth;
document.getElementById('txt').style.height = orignHeight;
document.getElementById('txt').style.display = "block";
}
}
<input type="button" value="取消设置" onclick='reset()'>
可以啊。这两个值 orignWidth、orignHeight 是多少。 貌似必须要加单位。
<div id="txt"></div>
<input type="button" value="取消设置" onclick='reset()'>
<script>
var orignWidth = '100px';
var orignHeight = '100px';
function reset()
{
var message=confirm("你确定要重置所有设置么?");
if(message==true)
{
document.getElementById('txt').style.color = "black";
document.getElementById('txt').style.backgroundColor = "#ccc";
document.getElementById('txt').style.width = orignWidth;
document.getElementById('txt').style.height = orignHeight;
document.getElementById('txt').style.display = "block";
}
}
</script>