Detailed explanation of how to create a simple almanac using JS
This article mainly introduces the method of making a simple almanac with js, including the implementation ideas and the implementation skills of each part of js, css and html. Friends in need can refer to it
This article describes the js production with examples Simple almanac method. Share it with everyone for your reference. The details are as follows:
Today I learned how to use js to make an almanac. I reviewed the usage of this by the way. It is a little different from the tab production. I used innerHTML newly. I hope I can stick to it. Dear js masters Also give me lots of advice.
Usage of innerHtml
Now use top.innerHTML="........."; method to write to the location of this id Enter the HTML code.
For example, top.innerHTML=""; a button will appear at the corresponding position of top!
Program implementation ideas:
1. Similar to a tab, except there is a p at the bottom;
2. Use of innerHTML
3. Use of arrays
① Definition: arr[0,1,2,3]
② Use: arr[0]
4. characters String connection
① Function: Connect two strings “+”
② Problem: The priority in the connection is solved with ()
implementation Source code:
JavaScript:
The code is as follows:
<script type="text/javascript"> window.onload=function() { var arr=[ '快过年了,大家一起去放鞭炮咯!', '马上上学了,不开心!', '妇女节快乐!', '很平淡的四月', '劳动光荣!', '儿童节快乐!', '好热的七月!', '八一建军节!', '又开学了哎!' ]; var op=document.getElementById('tab'); var oLi=op. getElementsByTagName ('li'); var oTxt=op.getElementsByTagName('p')[0]; var i=0; for(var i=0;i<oLi.length;i++) { oLi[i].index=i; oLi[i].onmouseover=function () { for(var i=0;i<oLi.length;i++) { oLi[i].className=''; } this.className='active'; oTxt.innerHTML='<h2>'+(this.index+1)+'月活动</h2><p>'+arr[this.index]+'</p>'; }; } }; </script>
CSS:
The code is as follows:
<style type="text/css"> * { padding: 0;margin: 0; } li { list-style: none; } body { background: #f6f9fc; font-family : arial; } .calendar { width: 210px; margin: 50px auto 0; padding: 10px 10px 20px 20px; background: #eae9e9; } .calendar ul { width: 210px; overflow: hidden; padding-bottom : 10px; } .calendar li { float: left; width: 58px; height: 54px; margin: 10px 10px 0 0; border: 1px solid #fff; background: #424242; color: #fff; text-align: center; cursor: pointer; } .calendar li h2 { font-size: 20px; padding-top: 5px; } .calendar li p { font-size: 14px; } .calendar .active { border: 1px solid #424242; background: #fff; color: #e84a7e; } .calendar .active h2 { } .calendar .active p { font-weight: bold; } .calendar .text { width: 178px; padding: 0 10px 10px; border: 1px solid #fff; padding-top: 10px; background: #f1f1f1; color: #555; } .calendar .text h2 {font-size: 14px; margin-bottom : 10px; } .calendar .text p { font-size: 12px; line-height : 18px; } </style>
HTML:
The code is as follows:
<body> <p id="tab" class="calendar"> <ul> <li class="active"><h2>1</h2><p>一月</p></li> <li><h2>2</h2><p>二月</p></li> <li><h2>3</h2><p>三月</p></li> <li><h2>4</h2><p>四月</p></li> <li><h2>5</h2><p>五月</p></li> <li><h2>6</h2><p>六月</p></li> <li><h2>7</h2><p>七月</p></li> <li><h2>8</h2><p>八月</p></li> <li><h2>9</h2><p>九月</p></li> <li><h2>10</h2><p>十月</p></li> <li><h2>11</h2><p>十一月</p></li> <li><h2>12</h2><p>十二月</p></li> </ul> <p class="text"> </p> </p> </body>
The rendering is as follows:
The above is the detailed content of Detailed explanation of how to create a simple almanac using JS. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to use WebSocket and JavaScript to implement an online speech recognition system Introduction: With the continuous development of technology, speech recognition technology has become an important part of the field of artificial intelligence. The online speech recognition system based on WebSocket and JavaScript has the characteristics of low latency, real-time and cross-platform, and has become a widely used solution. This article will introduce how to use WebSocket and JavaScript to implement an online speech recognition system.

WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

Introduction to how to use JavaScript and WebSocket to implement a real-time online ordering system: With the popularity of the Internet and the advancement of technology, more and more restaurants have begun to provide online ordering services. In order to implement a real-time online ordering system, we can use JavaScript and WebSocket technology. WebSocket is a full-duplex communication protocol based on the TCP protocol, which can realize real-time two-way communication between the client and the server. In the real-time online ordering system, when the user selects dishes and places an order

How to use WebSocket and JavaScript to implement an online reservation system. In today's digital era, more and more businesses and services need to provide online reservation functions. It is crucial to implement an efficient and real-time online reservation system. This article will introduce how to use WebSocket and JavaScript to implement an online reservation system, and provide specific code examples. 1. What is WebSocket? WebSocket is a full-duplex method on a single TCP connection.

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Golang is a powerful and efficient programming language that can be used to develop various applications and services. In Golang, pointers are a very important concept, which can help us operate data more flexibly and efficiently. Pointer conversion refers to the process of pointer operations between different types. This article will use specific examples to learn the best practices of pointer conversion in Golang. 1. Basic concepts In Golang, each variable has an address, and the address is the location of the variable in memory.

JavaScript is a programming language widely used in web development, while WebSocket is a network protocol used for real-time communication. Combining the powerful functions of the two, we can create an efficient real-time image processing system. This article will introduce how to implement this system using JavaScript and WebSocket, and provide specific code examples. First, we need to clarify the requirements and goals of the real-time image processing system. Suppose we have a camera device that can collect real-time image data
