当前位置:网站首页>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>
边栏推荐
- 拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
- 038. (2.7) less anxiety
- Redis insert data garbled solution
- HMS core machine learning service creates a new "sound" state of simultaneous interpreting translation, and AI makes international exchanges smoother
- None of the strongest kings in the monitoring industry!
- Nodejs教程之Expressjs一篇文章快速入门
- 【Redis设计与实现】第一部分 :Redis数据结构和对象 总结
- @PathVariable
- Deployment of external server area and dual machine hot standby of firewall Foundation
- C # use Oracle stored procedure to obtain result set instance
猜你喜欢
OneNote in-depth evaluation: using resources, plug-ins, templates
Statistical inference: maximum likelihood estimation, Bayesian estimation and variance deviation decomposition
20220211 failure - maximum amount of data supported by mongodb
Is it profitable to host an Olympic Games?
Interviewer: what is the internal implementation of ordered collection in redis?
拼多多败诉,砍价始终差0.9%一案宣判;微信内测同一手机号可注册两个账号功能;2022年度菲尔兹奖公布|极客头条
Seven original sins of embedded development
Aiko ai Frontier promotion (7.6)
2017 8th Blue Bridge Cup group a provincial tournament
ICML 2022 | Flowformer: 任务通用的线性复杂度Transformer
随机推荐
3D人脸重建:从基础知识到识别/重建方法!
新型数据库、多维表格平台盘点 Notion、FlowUs、Airtable、SeaTable、维格表 Vika、飞书多维表格、黑帕云、织信 Informat、语雀
愛可可AI前沿推介(7.6)
Common English vocabulary that every programmer must master (recommended Collection)
面试官:Redis中有序集合的内部实现方式是什么?
【论文解读】用于白内障分级/分类的机器学习技术
Infrared thermometer based on STM32 single chip microcomputer (with face detection)
【OpenCV 例程200篇】220.对图像进行马赛克处理
强化学习-学习笔记5 | AlphaGo
Laravel笔记-自定义登录中新增登录5次失败锁账户功能(提高系统安全性)
Yyds dry goods count re comb this of arrow function
document.write()的用法-写入文本——修改样式、位置控制
R語言可視化兩個以上的分類(類別)變量之間的關系、使用vcd包中的Mosaic函數創建馬賽克圖( Mosaic plots)、分別可視化兩個、三個、四個分類變量的關系的馬賽克圖
PHP saves session data to MySQL database
Reviewer dis's whole research direction is not just reviewing my manuscript. What should I do?
3D face reconstruction: from basic knowledge to recognition / reconstruction methods!
SAP UI5 框架的 manifest.json
基于深度学习的参考帧生成
Thinking about agile development
966 minimum path sum