您已经注意到一些网站为样式标记提供了ID,例如:
<style id=style-id></style>
Run Code Online (Sandbox Code Playgroud)
任何人都可以先解释为什么你会这样做以及doin的好处吗?
Dan*_*eam 51
所以你可以引用它(就像任何其他元素一样),即
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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
17462 次 |
| 最近记录: |