当前位置:网站首页>Native JS dynamically add elements
Native JS dynamically add elements
2022-06-25 15:51:00 【Full stack programmer webmaster】
Hello everyone , I meet you again , I'm your friend, Quan Jun .
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title> Native js Add elements dynamically </title>
<style>
.phone {
width: 200px;
height: 30px;
}
ul {
width: 200px;
border: 1px solid #eee;
text-align: right;
}
ul li{
list-style: none;
height: 50px;
line-height: 50px;
padding-right: 20px;
border-right: 2px solid #999;
}
ul li:hover {
color: #f00;
border-right: 2px solid #f00;
}
/* .circle1 {
width: 492px;
height: 499px;
border-radius: 50%;
background: #f00;
display: flex;
align-items: center;
justify-content: center;
}
.circle2 {
width: 260px;
height: 434px;
border-radius: 50%;
background: #fff;
} */
</style>
</head>
<body>
<div class="container">
<form action="" id="form">
</form>
<ul id="parentUI">
<li> Hello </li>
<li> About us </li>
<li> Help center </li>
</ul>
</div>
<script>
var formId = document.getElementById("form");
// Create elements input
var inputPhone = document.createElement("input");
// Set up input Properties of
inputPhone.setAttribute("class","phone");
inputPhone.type = "text";
inputPhone.value = " Please enter your mobile number ";
formId.appendChild(inputPhone);
// js Dynamic addition li
var ul = document.getElementById("parentUI");
var li = document.createElement("li");
li.setAttribute("class","list");
li.innerHTML = " Contact us ";
ul.appendChild(li);
</script>
</body>
</html>Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/152106.html Link to the original text :https://javaforall.cn
边栏推荐
- Brief introduction to class loading process
- Built in methods for data types
- Day01: learning notes
- Several relationships of UML
- Jz-065 path in matrix
- Super comprehensive custom deep copy function
- golang正则regexp包使用-05-扩展Expand()、根据正则切割Split()
- Sword finger offer 04 Find in 2D array
- Sword finger offer II 091 Paint the house
- Do you want to go to an outsourcing company? This article will give you a comprehensive understanding of outsourcing pits!
猜你喜欢

分享自己平时使用的socket多客户端通信的代码技术点和软件使用

Asynchronous processing of error prone points
Inter thread synchronization semaphore control

The style of the mall can also change a lot. DIY can learn about it!
Check whether the port number is occupied

解决Visio和office365安装兼容问题
Client development (electron) system level API usage 2

Popular cross domain

商城风格也可以很多变,DIY了解一下!

Resolve Visio and office365 installation compatibility issues
随机推荐
Sword finger offer 10- I. Fibonacci sequence
教务系统开发(PHP+MySQL)
Pytest测试框架笔记
Day01: learning notes
不要小看了积分商城,它的作用可以很大!
剑指 Offer 06. 从尾到头打印链表
leetcode-8. 字符串转换整数 (atoi)
AspNetCore&云效Flow持续集成
Desktop development (Tauri) opens the first chapter
TFIDF and BM25
golang reverse a slice
Go development team technical leader Russ Cox sends a document to share go's version control history
Yadali brick playing game based on deep Q-learning
The release of autok3s v0.5.0 continues to be simple and friendly
Why is it said that restarting can solve 90% of the problems
解决Visio和office365安装兼容问题
VectorDraw Developer Framework 10.1001 Crack
基于神经标签搜索,中科院&微软亚研零样本多语言抽取式摘要入选ACL 2022
Several relationships of UML
How to convert a recorded DOM to a video file