I want to protect my credit link using pure javascript, not jQuery, but I don't understand pure javascript.
some of the code I have made, and the results are as below. the code works ... but if I merge the two "IFs", one of them doesn't work.
so, how to combine the two codes if statement.
// THIS IF THE LINK ON THE HREF ATTRIBUTES ARE CHANGED
if (document.querySelector("#themelinks").href.indexOf("https://www.domain-name.com") != -1) {
// nothing
} else {
document.querySelector("#outer").innerHTML = "immediately include a credit link, thank you";
}
// THIS IS FOR IF THE ELEMENT IS DELETED
var hakcipta = document.getElementById("themelinks");
if (typeof hakcipta != "undefined" && hakcipta != null) {
// nothing
} else {
document.querySelector("#outer").innerHTML = "immediately include a credit link, thank you";
}
<div id="outer">
Theme by <a id="themelinks" href='https://www.domain-name.com'>WGs!</a>
</div>
Aucun commentaire:
Enregistrer un commentaire