js如何引入css文件
1、使用document.write方式输出引入css的link标签
<script>document.write('<link rel="stylesheet" href="main.css">');</script>2、使用createElement方法动态创建link标签,来引入css
<script>
new_element = document.createElement('link');
new_element.setAttribute('rel', 'stylesheet');
new_element.setAttribute('href', 'main.css');
document.body.appendChild(new_element);
</script>版权保护: 转载请保留链接: https://cgy.isi8.cn/js/241.html
