0

I have a requirement where I need to call the main css file using javascript into the header section. So basically instead of having the below line within the headers

<link rel="stylesheet" href="css/main.css">

How can I call it using javascript within the header tags?

0

1 Answer 1

1

You mean something like this

document.head.innerHTML+='<link rel="stylesheet" href="css/main.css">';
Sign up to request clarification or add additional context in comments.

8 Comments

I haven't tried it yet but looks good. thanks. what does += mean here?
@Bekki append operator?
Works perfect. :) I'll mark it as answered in couple of minutes. +25
@Bekki +25 will be after 9 mins, when you can accept :D Now you can give only +10.
@Bekki Yes, absolutely okay.
|

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.