<form name = "myForm" onsubmit="foo()">
<p class = "form-text">Name</p>
<input type = "text" name="name" />
<input type = "submit" />
</form>
//javascript (external file)
function foo(){
alert(document.forms["myForm"].name.value)
}
该法典是否有任何错误? 当我报到时,它就跑到一个白页,没有发生。
预期成果:贴有名称的警示箱