모든 입력 필드의 값을 재설정하려는 경우. 그런 다음 해결책이 될 수 있습니다.
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript">
function resetValues()
{
var x=document.getElementsByTagName("input");
for(i = 0; i<=x.length-1; i++)//x.length-1 i don't want to reset the value of the last button
{
if(x.item(i).type!="button")
x.item(i).value = "";
}
}
</script>
</head>
<body onload="resetValues()">
<input type="text" id="name"><br>
<input type="text" id="address"><br>
<input type="text" id="country"><br><br>
<input type="button" onclick="resetValues()" value="Reset values">
</body>
</html>
또는 특정 입력 필드를 재설정하지 않으려는 경우. 이것을 시도하십시오 :
//In you resetValues() function, replace the code with this
var x = document.getElementById("name");//your input element id
var y = document.getElementById("address");//your input element id
var z = document.getElementById("country");//your input element id
x.value = "";
y.value = x. value;
z.value = y.value;
희망, 이것은 당신을 위해 잘 작동합니다.
jQuery가 자바 스크립트를 사용한다고 생각했습니다. – leon
나는 당신을 쫓고 있는지 확신하지 못합니다. 정확히 내가하고있는 일은 window.history.back(); PHP 스크립트에서는 갈 길이 없습니다. – kbariotis
당신이 돌아 가면, 아약스를 사용하지 그래. – Daniel