18
rated 0 times
[
21]
[
3]
/ answers: 1 / hits: 95412
/ 13 Years ago, tue, february 21, 2012, 12:00:00
On clicking a link, it should redirect to the current page. How do I do this with JavaScript?
More From » jquery
On clicking a link, it should redirect to the current page. How do I do this with JavaScript?
Assuming you mean the link should refresh the current page, you can use window.location.reload()
. In jQuery it would look like this:
<a href="#" id="myLink">Refresh current page</a>
$("#myLink").click(function() {
window.location.reload();
});
In plain JS it would look like this:
document.querySelector("#myLink").addEventListener('click', function() {
window.location.reload();
});