当前位置:网站首页>Navigation bar switching, message board, text box losing focus
Navigation bar switching, message board, text box losing focus
2022-06-21 13:25:00 【zhangsan3333】
learn HTML Just look at this article (HTML Detailed explanation )
Web Message board
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<h1> Simple Web Message book </h1>
<textarea id="memo" cols="60" rows="6"></textarea><br />
<input type="button" value=" Add a message " onclick="saveStorage('memo');" />
<input type="button" value=" Empty data " onclick="clearStorage();" />
<input type="button" value=" Clear the last data " onclick="clearsingleStorage();" />
<hr />
<p id="msg"></p>
<script type="text/javascript"> //savaStorage Is a new message function function saveStorage(id) {
// obtain textarea Of value value var data = document.getElementById(id).value; // Get the current time var time = new Date().toUTCString(); // Take the current time as the key name ,textarea Of value value ( That is, the value entered by the user ) As the key value localStorage.setItem(time, data); // Show comments showMsg("msg"); } //showMsg Is a function that displays messages function showMsg(id) {
var result = '<table border="1">'; // Traverse locally stored data for (var i = 0; i < localStorage.length; i++) {
// obtain key value var key = localStorage.key(i); // obtain value value var value = localStorage.getItem(key); // Display the data result += "<tr><td>" + value + "</td><td>" + key + "</td></tr>"; } result += "</table>"; var target = document.getElementById(id); target.innerHTML = result; } // Show comments showMsg("msg"); //clearStorage Is a function to empty messages function clearStorage() {
// Empty data localStorage.clear(); // Show comments showMsg("msg"); } //clearsingleStorage Is a function to delete a single data function clearsingleStorage() {
localStorage.removeItem(localStorage.key(localStorage.length - 1)); // Show comments showMsg("msg"); } </script>
</body>
</html>

JS Learning notes (JavaScript Essential for basic learning )
Navigation bar style switch
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Title</title>
<style> #list li {
list-style-type: none; width: 100px; height: 50px; line-height: 50px; background-color: beige; text-align: center; float: left; } #list li.current {
background-color: red; } #list li a {
text-decoration: none; } </style>
</head>
<body>
<div id="menu">
<ul id="list">
<li class="current">
<a href="javascript:void(0)"> home page </a>
</li>
<li>
<a href="javascript:void(0)">HTML</a>
</li>
<li>
<a href="javascript:void(0)">CSS</a>
</li>
<li>
<a href="javascript:void(0)">JavaScript</a>
</li>
<li>
<a href="javascript:void(0)"> About </a>
</li>
<li>
<a href="javascript:void(0)"> help </a>
</li>
</ul>
</div>
<script> // Get all li label var liObjs = document.getElementById("list").getElementsByTagName("li"); // Loop traversal , Find each li Medium a, Register click events for (var i = 0; i < liObjs.length; i++) {
// Every li Medium a var aObj = liObjs[i].firstElementChild; aObj.onclick = function () {
// Put this a Where li The class styles of all sibling elements of the are removed for (var j = 0; j < liObjs.length; j++) {
liObjs[j].removeAttribute("class"); } // Currently clicked a Parent element of li( Click this a The parent element li), Set the background color this.parentNode.className = "current"; }; } </script>
</body>
</html>

jQuery For forms 、 Table operation ( Walk by and have a look )
The text box loses focus
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<style type="text/css"> body {
font: normal 12px/17px Arial; } div {
padding: 2px; } input, textarea {
width: 12em; border: 1px solid #888; } input:focus, textarea:focus {
border: 1px solid #f00; background: #fcc; } </style>
</head>
<body>
<form action="" method="post" id="regForm">
<fieldset>
<legend> Basic personal information </legend>
<div>
<label for="username"> name :</label>
<input id="username" type="text" />
</div>
<div>
<label for="pass"> password :</label>
<input id="pass" type="password" />
</div>
<div>
<label for="msg"> Details :</label>
<textarea id="msg" rows="2" cols="20"></textarea>
</div>
</fieldset>
</form>
</body>
</html>

边栏推荐
- 【深入理解TcaplusDB技术】Tmonitor后台一键安装
- Apache shardingsphere 5.1.2 release | new driving API + cloud native deployment to create a high-performance data gateway
- 微证券开户正规安全吗,怎么操作开户?
- SCCM基于已安装的 APP创建客户端集合并定期推送应用更新
- Six possible challenges when practicing Devops
- 【课程作业】浮点运算分析及精度改进
- Pre training weekly (50): no decoding converter, neural prompt search, gradient space dimensionality reduction
- 【深入理解TcaplusDB技术】TcaplusDB构造数据
- 5000 word analysis: the way of container security attack and defense in actual combat scenarios
- C language elementary (VII) structure
猜你喜欢

【课程作业】浮点运算分析及精度改进

Flink CDC MongoDB Connector 的实现原理和使用实践

The new plan for national treasures - the exclusive digital collection of the four museums is coming!

5000字解析:实战化场景下的容器安全攻防之道

ICLR2022 | 训练面向分子模拟的十亿级参数 GNN

Tami dog sharing: the way of property right transaction and the significance of data-based property right transaction market

Huawei cloud releases desktop ide codearts

修修补补一时爽,果断重构有担当——聊聊CRM分布式缓存优化

小程序直播互动功能运行在App里?

Turn to the countdown for coupon issuance! First look at the rules of interstellar pocket donation
随机推荐
CVPR2022 | 上科大x小红书首次提出动作序列验证任务,可应用于体育赛事打分等多场景
Babbitt yuancosmos daily must read: wechat may ban a official account for the first time on the grounds of "involving secondary transactions in digital collections", and the new regulations of the pla
Kube Prometheus grafana installation plug-in and grafana image renderer
Master the basic usage of SQLite3
2. data type
Explanation of common mesh generation methods in workbench
5. array
Summary of several ways to calculate distance
Is it safe to open a securities account by downloading the app of qiniu business school? Is there a risk?
curl常用参数详解及示例
如何阅读AI顶会论文?
MySQL约束(创建表时的各种条件说明)
Machine learning explores the metastable phase diagram of covalent carbon, which can be used to discover or design metastable materials in the future
2. reference
塔米狗项目解读:济宁华源项目管理有限公司34%股权转让
3. function improvement
6. functions
2022年中国手机银行年度专题分析
Questions and answers No. 43: application performance probe monitoring principle PHP probe
[deeply understand tcapulusdb technology] tcapulusdb import data