ITPub博客

首页 > > > document.write()内部编写style标签问题

document.write()内部编写style标签问题

作者:piny 时间:2019-09-11 15:10:30 0 删除 编辑
1 var age=18;
2 var showName=function (){
3     console.log('xiaozu');
4 };
5 showName();
6 document.write('<style>*{color:blue;}
7 </style>')

此处第6-7行有换行出错Uncaught SyntaxError: Invalid or unexpected token

1 var age=18;
2 var showName=function (){
3     console.log('xiaozu');
4 };
5 showName();
6 document.write('<style>*{color:blue;}</style>')

第6-7行无换行,成一行显示,无错误,

这是什么原因,直接在HTML中编写的话换行也没问题

来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/3034/viewspace-3147258/ ,如需转载,请注明出处,否则将追究法律责任。

下一篇: 菜单点击记忆
请登录后发表评论 登录
全部评论

注册时间:2020-05-13

  • 博文量
    137
  • 访问量
    8807