I tried but it didn't work because my ability in javascript is almost zero
var element = document.getElementById("change");
var going = "https://google.com";
if (typeof (element) == 'undefined' && element == null) {
window.location.replace((going));
}
else if (typeof (element).attr(href) != 'https://google.com') {
window.location.replace((going));
}
I want if #change does not exist then the page will redirect, but if there is but the href attribute is not what you want then the page will also redirect. It is my html code
<!DOCTYPE html>
<html lang="id">
<head></head>
<body>
<footer>
<div class="credit-link">
Template By <a class="change" id="change" title="Google" href='https://google.com'>Google</a>
</div>
</footer>
<script src="js/copy.js"></script>
</body>
</html>