I have made a anchro tag with 2 urls. One is href and other is data-url. When i click on button it should open a page in new tab which is correct. But additionally what i want is to reload the current page with the data-url link that i set.
So in the example i set href to google.com and it opens in new tab. Its correct but when we click the button i additionally the the current page to reload to data-url that is youtube.com.
HTML
<a href="https://www.google.com/" target="_blank" data-url="https://www.youtube.com/" id="agree">Click me</a>
JS
$('#agree').on('click', function(e) {
var url = $(this).data('url');
console.log(url);
// window.open(url);
location.reload(url);
});