Introduction to the use of jquery events and functions_jquery
May 16, 2016 pm 05:21 PMMethod 1:
Use this method to add events to elements when the page loads
$("#myElement").click(function(){
alert($(this). text());
})
Method 2:
Same as 1, you can also add events to elements after the page is loaded, such as creating new DOM elements
$("#myElement").bing('click' ,function(){
alert($(this).text());
})
2. Function declaration and named function expression
Function declaration:
function myFun1() {
$("div").hide();
}
Call: myFun1();
Function expression:
var myFun2 = function(){
$("div").hide ();
}
Call: #("#myElement").click(myFun2);
Difference: The difference in calling time, Function declarations can be used anywhere, named function expressions can only be used after declaration

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

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

Default parameters in C++ function declarations: a comprehensive analysis of their declaration and usage

What impact does the order of declaration and definition of C++ functions have?

What is the difference between C++ function declaration and definition?

C++ function declarations and definitions

C++ compilation error: function call does not match function declaration, how to solve it?
![[[nodiscard]] in C++ function declarations: Demystifying the consequences of ignoring return values](https://img.php.cn/upload/article/000/465/014/171455868319393.jpg?x-oss-process=image/resize,m_fill,h_207,w_330)
[[nodiscard]] in C++ function declarations: Demystifying the consequences of ignoring return values

Detailed syntax of C++ function declaration: from syntax analysis to standard usage analysis

Use jQuery to implement value change event binding of select elements
