js添加css到head中

<script>
    var style = document.createElement("style");
    style.type = "text/css";
    style.innerHTML = 'body{background:pink;}';
    window.document.head.appendChild(style);
</script>

  

posted @ 2021-12-01 09:44  仔行天下  阅读(316)  评论(0编辑  收藏  举报