


js and jquery batch binding event passing parameters 1 (new pig original)_javascript skills
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:
< ;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" />
$(function () {
var i;
for (i = 1; i < = 7; i ) {
$("#btn" i).bind("click", { id: i }, dis);
}
});
function dis(evt) {
alert(evt.data.id);
}

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 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.

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 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

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

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? 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

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

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
