Removing <style> Tags from <head>

The software of our forms generates several tags <style>in a section <head>, none of which are needed (or not needed).

How can I delete them? I tried the following, but I think my logic is flawed here ... I thought I needed to target the parent ( <head>) to remove the child, but I think I'm too simplistic:

var hs = document.getElementsByTagName('style');
for (var i=0, max=all.length; i < max; i++) {
    hs[i].parentNode.removeChild(hs[i]);
}

Am I really in the confusion of an array?

+3
source share
1 answer

Try

var hs = document.getElementsByTagName('style');
for (var i=0, max = hs.length; i < max; i++) {
    hs[i].parentNode.removeChild(hs[i]);
}

max = all.length, all, , hs.length. max = hs.length , 0.

+2

All Articles