日期:2014-05-16 浏览次数:20398 次
<html> <body> <script type="text/javascript"> function del(){ var str = document.content.text1.value; str=str.replace(document.content.text1.value,""); document.content.text1.value=str; } </script> <form name="content" method="post" action=""> <input name = "compare" type = "button" value = "compare" onclick = "del()"/> <input name = "text1" type = "text" size = "10" value = "enter"/> </body> </html>
------解决方案--------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>无标题文档</title> </head> <body> <script type="text/javascript"> function deleteValue(){ document.getElementById("text1").value = ""; } </script> <form name="content" method="post" action=""> <input name = "compare" type = "button" value = "compare" onclick = "deleteValue()"/> <input name = "text1" type = "text" size = "10" value = "enter" id="text1"/> </body> </html> delete是保留字,不能用做函数名的