我正在使用名为showDate()的JavaScript函数传递参数(称为id)。我试图让函数显示与传递给函数调用中的函数的innerHTML属性的日期。JavaScript将不会使用HTML DOM显示日期
这里是我的代码:
<!DOCTYPE html>
<html>
<head>
<title>My bored html</title>
<script type = "text/javascript">
function showDate(id)
{
document.getElementById(id).innerHTML = Date();
}
</script>
</head>
<p id = "Datepara" style = "font-family:comic sans ms;color:orange;text-align:center;font-size:25px;">
Date: 24/9/12 <br /><br /><br/>
</p>
<input type = "button" onclick = "showDate(Datepara)" value = "Display today's date" />
</body>
</html>
该死的!我知道这是非常微不足道的东西xD – imulsion