I have a webpage that I am creating, and I am trying to add a link to the top that will add a css file. I think that it is not working because I load the page, then add the link element and it never actually puts the styles found in the css file to the elements. I tried having it reload the page using location.reload(), but that took the link element away from the page. Any suggestions on how to do this would be great. I would prefer not to use jquery, but I can if needed.
Current Code:
function findCss() {
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", "styles/index.css")
}
window.onload = findCss;