I have been going through some code and converting all the jQuery to vanilla JS. Below is some code I converted successfully (commented out is the jQuery). I was having some trouble appending it to the head until I added [0] at the end.I know square brackets are used when accessing an array, but I'm not exactly sure why they were needed in this instance. Could someone explain?
var head = document.getElementsByTagName('head')[0];
var linkScript = document.createElement('link');
linkScript.type = 'text/css';
linkScript.rel = 'stylesheet';
linkScript.href = purecommHostFiles + 'style.css';
head.appendChild(linkScript);
// $('<link>')
// .appendTo('head')
// .attr({
// type: 'text/css',
// rel: 'stylesheet',
// href: purecommHostFiles + 'style.css'
// });