当前位置:网站首页>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>
边栏推荐
- Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
- Word bag model and TF-IDF
- Nodejs tutorial expressjs article quick start
- OneNote in-depth evaluation: using resources, plug-ins, templates
- Reinforcement learning - learning notes 5 | alphago
- 新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
- Web开发小妙招:巧用ThreadLocal规避层层传值
- Dynamically switch data sources
- Web开发小妙招:巧用ThreadLocal规避层层传值
- [200 opencv routines] 220 Mosaic the image
猜你喜欢
2022 fields Award Announced! The first Korean Xu Long'er was on the list, and four post-80s women won the prize. Ukrainian female mathematicians became the only two women to win the prize in history
Seven original sins of embedded development
【微信小程序】運行機制和更新機制
全网最全的知识库管理工具综合评测和推荐:FlowUs、Baklib、简道云、ONES Wiki 、PingCode、Seed、MeBox、亿方云、智米云、搜阅云、天翎
2017 8th Blue Bridge Cup group a provincial tournament
15 millions d'employés sont faciles à gérer et la base de données native du cloud gaussdb rend le Bureau des RH plus efficace
OAI 5g nr+usrp b210 installation and construction
监控界的最强王者,没有之一!
1_ Introduction to go language
愛可可AI前沿推介(7.6)
随机推荐
How to turn a multi digit number into a digital list
Nodejs教程之Expressjs一篇文章快速入门
华为设备命令
字符串的使用方法之startwith()-以XX开头、endsWith()-以XX结尾、trim()-删除两端空格
R language visualizes the relationship between more than two classification (category) variables, uses mosaic function in VCD package to create mosaic plots, and visualizes the relationship between tw
2017 8th Blue Bridge Cup group a provincial tournament
el-table表格——获取单击的是第几行和第几列 & 表格排序之el-table与sort-change、el-table-column与sort-method & 清除排序-clearSort
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
What is the difference between procedural SQL and C language in defining variables
【OpenCV 例程200篇】220.对图像进行马赛克处理
OAI 5G NR+USRP B210安装搭建
Yyds dry inventory run kubeedge official example_ Counter demo counter
SAP Fiori应用索引大全工具和 SAP Fiori Tools 的使用介绍
Opencv learning example code 3.2.3 image binarization
Can novices speculate in stocks for 200 yuan? Is the securities account given by qiniu safe?
C language games - three chess
HMS Core 机器学习服务打造同传翻译新“声”态,AI让国际交流更顺畅
基于深度学习的参考帧生成
Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
Aike AI frontier promotion (7.6)