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?
2 Answers
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.
:beforeis a pseudo-element.