当前位置:网站首页>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>
边栏推荐
- Mtcnn face detection
- Common English vocabulary that every programmer must master (recommended Collection)
- Regular expression collection
- Nodejs教程之让我们用 typescript 创建你的第一个 expressjs 应用程序
- 【论文解读】用于白内障分级/分类的机器学习技术
- 1_ Introduction to go language
- 嵌入式开发的7大原罪
- Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
- After working for 5 years, this experience is left when you reach P7. You have helped your friends get 10 offers
- Nodejs tutorial let's create your first expressjs application with typescript
猜你喜欢

请问sql group by 语句问题

Chris LATTNER, the father of llvm: why should we rebuild AI infrastructure software

Opencv learning example code 3.2.3 image binarization

监控界的最强王者,没有之一!

【mysql】游标的基本使用

966 minimum path sum

1500萬員工輕松管理,雲原生數據庫GaussDB讓HR辦公更高效

3D人脸重建:从基础知识到识别/重建方法!

Redis insert data garbled solution

Manifest of SAP ui5 framework json
随机推荐
KDD 2022 | realize unified conversational recommendation through knowledge enhanced prompt learning
The biggest pain point of traffic management - the resource utilization rate cannot go up
请问sql group by 语句问题
967- letter combination of telephone number
OneNote 深度评测:使用资源、插件、模版
代理和反向代理
HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
[MySQL] basic use of cursor
Mtcnn face detection
'class file has wrong version 52.0, should be 50.0' - class file has wrong version 52.0, should be 50.0
2017 8th Blue Bridge Cup group a provincial tournament
Vim 基本配置和经常使用的命令
监控界的最强王者,没有之一!
el-table表格——sortable排序 & 出现小数、%时排序错乱
C language games - three chess
【深度学习】PyTorch 1.12发布,正式支持苹果M1芯片GPU加速,修复众多Bug
[200 opencv routines] 220 Mosaic the image
What is the difference between procedural SQL and C language in defining variables
C # use Oracle stored procedure to obtain result set instance
Deployment of external server area and dual machine hot standby of firewall Foundation