下面的JS代码当用户点击提交按钮后,通过元素的textContent或者innerHTML动态指定元素的内容
<script type="text/javascript"> function showCard() { var message = document.getElementById("CCN").value; var element = document.getElementById("mycreditcardnumber"); element.textContent = message; //for Firefox element.innerHTML = message; //for IE (why can't we all just get along?) return true; } </script> <form name="dynamic" method="get"> <span>Enter Your Credit Card Number:</span> <input type="text" id="CCN" name="CCN" value="CCN" /> <input type="button" value="submit" onclick="showCard()" /> </form> <p>Verify your Credit Card Number: <span id="mycreditcardnumber">0000-00-0000-00 </span> </p>