1

I'd like to use both the CSS :before pseudoclass and the jQuery .before() method to generate the same content (a <li> element) on a page for maximum browser compatibility (ie, both IE 6-7 AND other browsers with JavaScript disabled). Is this possible? Which will override the other?

1
  • 1
    :before is a pseudo-element. Commented Jun 19, 2011 at 21:21

2 Answers 2

3

Add a class to the element (say, class="no-js") and remove it with javascript/jquery. Then style that class for the no-javascript case, then if, the user doesn't have javascript, that element will still have the style desired. Then, of course, if javascript is enabled, once you remove the class you can go ahead and do whatever you wish with javascript.

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

Comments

1

You could also use the <noscript> tag around the css that has the :before on it. Just make sure it's css on the page and not linked.

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.