Home >Web Front-end >JS Tutorial >What is the difference between JQuery click() and onclick()

What is the difference between JQuery click() and onclick()

coldplay.xixi
coldplay.xixiOriginal
2020-11-27 15:47:2410807browse

The difference between JQuery click() and onclick(): 1. onclick is a binding event, telling the browser what to do when the mouse clicks; 2. The main function of the click method is to trigger the onclick event of the element that calls the click method. .

What is the difference between JQuery click() and onclick()

The operating environment of this tutorial: Windows 7 system, jquery version 1.10.0. This method is suitable for all brands of computers.

The difference between JQuery click() and onclick():

1. onclick is a binding event that tells the browser what to do when the mouse clicks

2. The main function of the click() method is to trigger the onclick event of the element that calls the click method.

3. When click() is clicked, the onclick() function of the corresponding element is first executed, and then click(). The example is as follows:

JS code test.js:

$("#testclick").click(function(){
     console.log("$(\"#testclick\").click"); 
 }); 
function test123(){ 
  console.log("function test()"); 
}
rrree

Related learning recommendations: javascript video tutorial

The above is the detailed content of What is the difference between JQuery click() and onclick(). For more information, please follow other related articles on the PHP Chinese website!

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