0

I want to insert a style in external style sheet. Can anyone help me to do this?

The below code is not useful for me because it insert css as inline

$("#id").css('border','2px solid red')
3
  • You want to add these lines in altogether diffrent file? Commented Oct 26, 2013 at 11:23
  • I want to add the css using jquery in external css file Commented Oct 26, 2013 at 11:25
  • 3
    It's not very clear what exactly you're trying to achieve and why you want to do this. Please add more details, so that somebody can help you with an appropriate solution. Commented Oct 26, 2013 at 11:25

1 Answer 1

1

I think what you're saying is: using your example code it inserts as inline styles rather than creating its own external style sheet with the style that is then applied to your DOM.

If so read this. It's from 1996 (woo!) but shows how to create <style> elements using javascript (so your CSS will live in the HTML <head> and not be inline. In terms of using Javascript to create external stylesheets? No idea, hopefully someone else can help.

Edit: found this on SO: How to create a <style> tag with Javascript so no need to rely on something from '96.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.