开发者

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
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜