输出内容(document.write)

document.write() 直接在页面中输出内容

第一种 直接输出

   document.write("I Love Javascript !") //输出内容为:I Love Javascript !

第二种 通过变量输出

   var mystr = "hallo world!";

   document.write(mystr); //输出结果为:hallo world!

第三种 输出多项内容,内容之间用+号链接

    var mystr = "hello";

    document.write(mystr+"I Love Javascript"); //输出内容为:hello I Love Javacsript

第四种 输出HTML标签,标签使用""括起来

   var mystr = "hello";

   document.write(mystr+"<br>");  //输出的内容会换行

   document.write("javascript");  

 

posted @ 2016-05-05 15:46  zxc_886  阅读(282)  评论(0编辑  收藏  举报