我有一个文本字段,它应该在按下提交按钮时更改页面上的元素,其中包含文本。我将值传递给 javascript 函数。它不起作用,谁能告诉我该怎么做/我做错了什么?
这是我的代码:
<html>
<head>
<script type = "text/javascript">
function submitText(string, id)
{
document.getElementById(id).innerHTML = string;
}
</script>
</head>
<body>
<p id = "Datepara" style = "font-family:comic sans ms;color:orange;text-align:center;font-size:25px;">
Date Created: 24/9/12 <br /><br /><br/>
</p>
<input id = "changetext" type = "text" value = "Enter text to display text in this webpage!"/>
<input id = "submit" type = "button" onclick = "submitText('Datepara','document.getElementById("changetext").value;'" value = "Submit" />
</body>
</html>