Home Web Front-end JS Tutorial js and jquery batch binding event passing parameters 1 (new pig original)_javascript skills

js and jquery batch binding event passing parameters 1 (new pig original)_javascript skills

May 16, 2016 pm 06:24 PM
batch Binding events

Copy code The code is as follows:






The following is the code combined with jquery, the principle is the same
When using javascript to batch bind elements on the page and pass the incremental number, you need to write as follows: Code for the
part:
Copy code The code is as follows:

< ;input type="button" id="btn1" value="Button 1" />

< ;input type="button" id="btn3" value="Button 3" />

< ;input type="button" id="btn5" value="Button 5" />

< ;input type="button" id="btn7" value="Button 7" />

Part of the code:
Copy code The code is as follows:

$(function () {
var i;
for (i = 1; i < = 7; i ) {
$("#btn" i).bind("click", { id: i }, dis);
}
});

function dis(evt) {
alert(evt.data.id);
}
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to batch rename file suffixes in win10 How to batch rename file suffixes in win10 Jul 06, 2023 pm 07:37 PM

How to batch rename file suffixes in win10? Nowadays, many users are using the Win10 system, and when we usually use computers, we often use a lot of shortcut keys, because shortcut keys can make our operations more convenient, so how do we rename files in batches? Below, the editor will introduce to you the operation of batch renaming files in Win10. How to batch rename files in Win10 1. Select all the files you want to rename. 2. Right-click on a selected file and select Rename. 3. After a file is renamed, other files will be marked with serial numbers in turn. The method is very simple, but when modifying, you need to pay attention to the order of the files and the sorting position of the modified sample files. The serial number starts from the modified sample file.

Use jQuery to implement value change event binding of select elements Use jQuery to implement value change event binding of select elements Feb 24, 2024 am 08:51 AM

jQuery is a widely used JavaScript library used to simplify DOM manipulation, event handling, animation effects and other operations on web pages. In web development, it is often necessary to bind events to page elements, and binding select option change events is one of the common requirements. This article will introduce how to use jQuery to bind select option change events and provide specific code examples. 1. Introduce the jQuery library first, in the HTML document

How to batch insert data in MyBatis How to batch insert data in MyBatis Feb 23, 2024 pm 06:00 PM

How to implement the batch adding function in MyBatis requires specific code examples. In actual development, we often encounter situations where we need to add data in batches, such as batch inserting multiple records into the database. How to implement the batch addition function when using MyBatis, an excellent persistence layer framework? The following will introduce how to implement the batch addition function in MyBatis, and attach specific code examples. First, we need to write the corresponding SQL statement in the Mapper.xml file and use INSER

MyBatis batch query statement examples and implementation guide MyBatis batch query statement examples and implementation guide Feb 18, 2024 pm 12:01 PM

Examples and code examples of MyBatis batch query statements Introduction: In actual development, when the amount of data is large, we often need to use batch queries to improve query efficiency. MyBatis provides good support for batch queries, which can greatly reduce the number of database accesses and improve query performance. This article will introduce examples and code examples of batch query using MyBatis. 1. What is batch query? Batch query refers to executing multiple query statements at one time and returning multiple query results. This can reduce the database

How to use commands to batch modify file names under CentOS? How to use commands to batch modify file names under CentOS? Jan 05, 2024 am 08:09 AM

I encountered a new problem today. What if I want to cut off the suffixes in batches? The specific commands are as follows: find-name"*.txt"|foriin*;domv$i`echo$i|sed's/\.txt//g'`;donefind-name"*.txt"|awk-F'.' '{print$1}|xargsmv{}.txt{}If you only want to modify the suffix name, use rename. The command is as follows: rename.txt.bk*

How to send bulk personalized HTML emails using PHP and PHPMAILER? How to send bulk personalized HTML emails using PHP and PHPMAILER? Jul 21, 2023 am 10:06 AM

How to send bulk personalized HTML emails using PHP and PHPMailer? With the development of the Internet, email has become an indispensable part of people's daily lives. In the business field, sending personalized information to customers or users via email has become a common marketing tool. Using PHP and the PHPMailer library, we can easily send bulk personalized HTML emails. This article will introduce how to use PHP and PHPMailer to achieve this function. 1. Preparation work

Introducing how to use jQuery to bind selected element change events Introducing how to use jQuery to bind selected element change events Feb 24, 2024 am 08:24 AM

Introduction to the method of using jQuery to bind the change event of the select element. In web development, it is often necessary to interact with form elements, and the select element is one of the commonly used form elements. Using jQuery, you can easily monitor and process the change events of the select element. This article will introduce how to use jQuery to bind select element change events, and provide specific code examples. First, we need to ensure that the jQuery library file is introduced into the page, which can be done through C

jQuery practical tips: Binding select element change events jQuery practical tips: Binding select element change events Feb 24, 2024 am 09:00 AM

Practical tips for using jQuery to bind select change events. In front-end development, we often encounter situations where we need to dynamically display different content based on the drop-down menu options selected by the user. In order to achieve this function, we can use jQuery to bind the change event of the select element and trigger the corresponding operation based on the user's selection. This article will introduce how to use jQuery to achieve this function and provide specific code examples. 1.Introduce the jQuery library before using jQuery

See all articles