I have created a simple button. Now what I want that, if anyone bring any changes to my css code of #btns
id css from <style> .... <.style>
tag, like cnages property value, or remove any property, or add any extra property that not in <style> .... <.style>
css tag or override css of <style> .... <.style>
tag, I mean if anyone touch on css code, then it will be redirect to [https://www.google.com/](https://stackoverflow.com)
website. How can I do it using jquery.
I think we should write the same css code inside jquery and then compare, where we must give priority the css code which is inside Js code.
Heres my approach. But it redirects without any reason, I mean if both CSS are same, though it redirects.
<!DOCTYPE html>
<html>
<head>
<style id="styleTag">
#btns {
background: #00c9c9!important;
border: none!important;
padding: 12px 16px!important;
color: #fff!important;
}
</style>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script>
$(document).ready(function() {
var st = `
#btns {
background: #00c9c9!important;
border: none!important;
padding: 12px 16px!important;
color: #fff!important;
}
`;
var js = $("#styleTag").text().trim();
if (st !== js) {
window.location.href = "https://www.google.com/";
}
});
</script>
</head>
<body>
<button id="btns"> A Button </button>
</body>
</html>