Home > Web Front-end > JS Tutorial > JQuery implementation method of passing parameters when binding events_jquery

JQuery implementation method of passing parameters when binding events_jquery

WBOY
Release: 2016-05-16 18:44:47
Original
960 people have browsed it

For example, if I want to pass the current text box as a parameter to the function represented by functionName in $(":text").bind("keyup",funcionName);, how should I write it? I tried $(":text").bind("keyup",functionName(this)); This is wrong!

1. Using this directly in functionName is to refer to the element itself of the trigger time Quote, if you need functionName to have more parameters, you can use it like this:

2.$(":text").bind("keyup",function(){
funcionName(arg1,arg2 ,arg3,arg4);
});

3. If there is a parameter with event name, you can pass it
$(:text").bind("keyup", function(event) {
event = event || window.event;
var target = event.target; //This is the control that triggers the event
});

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template