当前位置:网站首页>document. Usage of write () - write text - modify style and position control
document. Usage of write () - write text - modify style and position control
2022-07-06 21:10:00 【viceen】
document.write() Usage of - Write text —— Modify the style 、 position control
1、 Write text
Page loading can write , Without rewriting the page .
grammar :document.write(content)
Parameters :
content: Mandatory . character string , It can be a variable or an expression with a string value , What is written often includes HTML Markup language
utilize document.write() To write text
<body>
<h1>Head</h1>
<script> document.write('<p>hello document</p>'); </script>
<h2>Tail</h2>
</body>
This is h1
and h2
A script is embedded between , Use document.write() To write a p
label .
Refresh the page , You can see that the final result is
Head
hello document
Tail
That is, the text is inserted at the position where the script is executed . This is because , The browser parses HTML structure DOM When , If you encounter script
Will pause , analysis script
And execute , Then continue to parse the rest HTML.( Blocking is going on )
Then check in the browser DOM Structure , Will find script
And h2
There is one more p
, Browser is finished parsing h1
after , meet script
And execute it , here document.write
Put a paragraph HTML Write code to the document stream ,script After execution , The browser will parse character string , For newly added p
The tag is parsed .
<script>
var sum_count="Sum:";
document.write("<span>"+sum_count+"</span>")
</script>
<style>
span {
display:inline-block;
width: 30px;
}
</style>
边栏推荐
- C language operators
- Opencv learning example code 3.2.3 image binarization
- 1500萬員工輕松管理,雲原生數據庫GaussDB讓HR辦公更高效
- Thinking about agile development
- 2022菲尔兹奖揭晓!首位韩裔许埈珥上榜,四位80后得奖,乌克兰女数学家成史上唯二获奖女性
- 967- letter combination of telephone number
- 15million employees are easy to manage, and the cloud native database gaussdb makes HR office more efficient
- The most comprehensive new database in the whole network, multidimensional table platform inventory note, flowus, airtable, seatable, Vig table Vika, flying Book Multidimensional table, heipayun, Zhix
- [wechat applet] operation mechanism and update mechanism
- R語言可視化兩個以上的分類(類別)變量之間的關系、使用vcd包中的Mosaic函數創建馬賽克圖( Mosaic plots)、分別可視化兩個、三個、四個分類變量的關系的馬賽克圖
猜你喜欢
Common English vocabulary that every programmer must master (recommended Collection)
嵌入式开发的7大原罪
Pycharm remote execution
审稿人dis整个研究方向已经不仅仅是在审我的稿子了怎么办?
OAI 5g nr+usrp b210 installation and construction
for循环中break与continue的区别——break-完全结束循环 & continue-终止本次循环
【滑动窗口】第九届蓝桥杯省赛B组:日志统计
基于深度学习的参考帧生成
硬件开发笔记(十): 硬件开发基本流程,制作一个USB转RS232的模块(九):创建CH340G/MAX232封装库sop-16并关联原理图元器件
Is it profitable to host an Olympic Games?
随机推荐
How do I remove duplicates from the list- How to remove duplicates from a list?
@GetMapping、@PostMapping 和 @RequestMapping详细区别附实战代码(全)
请问sql group by 语句问题
Pat 1078 hashing (25 points) ⼆ times ⽅ exploration method
What are RDB and AOF
R语言做文本挖掘 Part4文本分类
Common English vocabulary that every programmer must master (recommended Collection)
What is the problem with the SQL group by statement
Opencv learning example code 3.2.3 image binarization
Spiral square PTA
PG basics -- Logical Structure Management (transaction)
After working for 5 years, this experience is left when you reach P7. You have helped your friends get 10 offers
Vim 基本配置和经常使用的命令
【论文解读】用于白内障分级/分类的机器学习技术
OSPF多区域配置
968 edit distance
el-table表格——sortable排序 & 出现小数、%时排序错乱
js中,字符串和数组互转(二)——数组转为字符串的方法
Xcode6 error: "no matching provisioning profiles found for application"
Mtcnn face detection