js 控制 head 元素 隐藏与显示

就把那段script加到head之间。
<script type="text/javascript">if(screen.width<=1240){document.write("<link rel='stylesheet' type='text/css' href='css/index_1240.css' />");}</script>

DOM中document对象的write方法,将一段HTML代码或是一段文本内容输出到文档,以使浏览器可以动态处理.

原文地址:https://www.cnblogs.com/htys/p/3947684.html