function change(){
item = document.getElementById("first");
item.value = "second";
item.id = "second";
}
ob = document.getElementById("first");
ob.addEventListener("click",change);
<input id="first" type="button" value="first">
When you click the input ,it turned into
<input id="second" type="button" value="second">
Now my requirement is ,to write a js code ,when you click the input whose id is second, the webpage will refresh,that is to say , to change the current input element:
<input id="second" type="button" value="second">
into the previous
<input id="first" type="button" value="first">
Here is my try.
function change(){
item = document.getElementById("first");
item.value = "second";
item.id = "second";
}
ob = document.getElementById("first");
ob.addEventListener("click",change);
function previous(){
document.execCommand('Refresh')
}
ob = document.getElementById("second");
ob.addEventListener("click",previous);
<input id="first" type="button" value="first">
error: Uncaught TypeError: Cannot read property 'addEventListener' of null at line27.
from How to refresh the webpage after changed one time?
No comments:
Post a Comment