a href link click does not open in new window
The idea is counting the number times people click on a link (the example is about a button click)
I modified it and the count clicking works but no new page is opened.
- <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Click Counter</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('body').on('click', 'a', function(event){
event.preventDefault();
var currentNumber = $('#currentNumber').text();
$.ajax({
method: 'POST',
url: 'counter.php',
data: {currentNumber : currentNumber}
})
.done(function(newNumber){
$('#currentNumber').text(newNumber);
});
});
});
</script>
</head>
<body>
<center>
<br><br><br><br>
<div id="currentNumber">0</div>
<!--
<button type="button">Click To Add One</button>
-->
<a href="https://www.jquery.com" target="_new">https://www.jquery.com</a><br>
</center>
</body>
</html>
the counter script is the same as in the example in the link
how come the link is not opened in a new tab and how can I fix it ?