


How to use javascript to change the button to display text after clicking it_javascript skills
The example in this article describes the method of using javascript to change the button to display text after clicking. Share it with everyone for your reference. The specific implementation method is as follows:
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>显示一些按钮,如果点击了, 当前点击的按钮文本变为“点了”,其他按钮文本变为“没点”</title> <script type="text/javascript"> //为所有按钮动态添加事件 function IniButtonEvent() { var Items = document.getElementsByTagName("input"); for (var i = 0; i < Items.length; i++) { var objTmp = Items[i]; if (objTmp.type == "button") { objTmp.onclick = ButtonClick; } } } function ButtonClick() { var Items = document.getElementsByTagName("input"); for (var i = 0; i < Items.length; i++) { var objTmp = Items[i]; if (objTmp.type == "button") { //判断是否是按钮 //window.event.srcElement触发当前事件的元素 //用来判断是否是当前单击的按钮 if (objTmp == window.event.srcElement) { objTmp.value = "点了"; } else { objTmp.value = "没点"; } } } } </script> </head> <body onload="IniButtonEvent()"> 显示一些按钮,如果点击了,当前点击的按钮文本变为“点了”, 其他按钮文本变为“没点”<br /> <input type="button" value="没点" /> <input type="button" value="没点" /> <input type="button" value="没点" /> <input type="button" value="没点" /> <input type="button" value="没点" /> </body> </html>
I hope this article will be helpful to everyone’s JavaScript programming design.

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

AI Hentai Generator
Generate AI Hentai for free.

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.

There could be several reasons why your Windows laptop won't boot. Memory failure, dead battery, faulty power button, or hardware issues are all common causes. Here are some solutions to help you resolve this issue. Laptop won't turn on after pressing the power button If your Windows laptop still won't turn on after pressing the power button, here are some steps you can take to resolve the issue: Is your laptop fully charged? Perform a hard reset to clean your laptop Reseat the memory Transparent CMOS type battery Take your laptop for repair. 1] Is your laptop fully charged? The first thing to do is to check if your laptop is fully charged. Laptop won't start if battery is drained

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

What should I do if there is no response when clicking the web button in IE browser? If there is no response when we click the web button, we can set it in the compatibility view! When some friends are using the IE browser, they find that the browser will not respond when clicking the button on the web page. In this way, we cannot use the functions of the web page. How can we set it up? The editor has compiled the IE browser below. How to solve the problem of the browser not responding when clicking the web button? If not, follow me and read on! IE browser does not respond when clicking the web button. Solution: 1. Open IE browser, click the [Tools] button on the operation bar, and click [Compatibility View] settings, as shown in the figure. 2. In the [Compatibility View] setting page, click the [Add] button on the right and fill in the website.

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.

After the release of the iPhone 15 series, there have been constant revelations about the appearance and configuration of Apple’s new iPhone 16. What does iPhone 16 look like? Is there any improvement in iPhone 16? Recently, an overseas blogger showed off the design of the iPhone 16 series. The overall design is basically the same as the iPhone 15 series. As you can see from the picture, the entire iPhone 16 series is equipped with a new "shoot" button as standard, allowing users to take photos more conveniently. In addition, other design details are still unknown. The message shows that this new button will be used to shoot videos and is located below the power button. Previous news has mentioned that it may be a capacitive solid-state button, but recent reports indicate that it should still be a

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

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
