Why would you give a style tag an id

前端 未结 1 865
执笔经年
执笔经年 2021-01-03 17:40

Hi have noticed a few sites that give the style tag an id such as:


Can anyone explain firstly why y

相关标签:
1条回答
  • 2021-01-03 18:23

    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 讨论(0)
提交回复
热议问题