I want to refresh my website after clicking on a specific area (container)
Any ideas?
THANKS!
I want to refresh my website after clicking on a specific area (container)
Any ideas?
THANKS!
You can use Location.reload()
API interface (https://developer.mozilla.org/ru/docs/Web/API/Location/reload)
So the answer could look as follows:
document.querySelector('you-area-selector-here').addEventListener((click) => {
window.location.reload(true);
})
true
flag is required to be sure the page was reloaded from server, not from cache.
It is not a good practice to mix js with HTML.
I would do it this way:
let refreshPage = document.querySelector('#div1').addEventListener('click', => {
location.reload();
})
note: you must give id or class to the element you are trying to select in this function. There are other way of doing it i.e = document.querySelectorAll, getElementById, getElementByClassName, getElementByTagName.