Can someone help me figure out what's wrong with my code? I need to remove all "link" tags with the attribute "rel = "stylesheet"
Here is the HTML code I am working with:
<html>
<head>
<title>teset</title>
<meta charset="utf-8" />
<meta name="description" content="test." />
<meta name="author" content="Me" />
<link rel="author" href="www.mysite.uk" />
<link rel="stylesheet" type="text/css" href="www.mysite.uk/css/style.css />
<link rel="stylesheet" type="text/css" href="www.mysite.uk/css/style2.css />
</head>
<script src = "deleteCSS.js"></script>
<body onload="noCSS()">
<p> test !!</p>
</body>
</html>
Below is my JavaScript code (deleteCSS.js):
function noCSS(){
//I save tag "link"
var CSSlink = document.getElementsByTagName("link");
var CSSatt = CSSlink.getAttribute("rel");
for (var i=0; i < CSSlink.length; i++){
if (CSSatt[i] == "stylesheet"){
CSSlink[i].remove(); }
}
}