Why would you give a style tag an id
Hi have noticed a few sites that give the style tag an id such as:
<style id=style-id></style>
Can anyone explain firstly why you would do this and also the bene开发者_开发百科fits of doin so?
So you can reference it (just like any other element), i.e.
var styles = document.getElementById('style-id');
// do anything you want, like
styles.parentNode.removeChild(styles); // remove these styles
styles.setAttribute('href', 'alternate-styles.css'); // change the style
精彩评论