Home > Web Front-end > JS Tutorial > body text

The difference between click event and onclick event

little bottle
Release: 2019-04-16 09:41:22
forward
5002 people have browsed it

The names of the click event and the onclick event are very similar, which makes the editor wonder what is the difference between the two. So I searched for relevant information online, and this article talks about the difference between the two.

1, api explanation of click event (in jquery)

Return value: jQueryclick([[data],fn] )

Overview

Trigger the click event of each matching element.

This function will call and execute all functions bound to the click event.

Parameters

fnFunctionV1.0

Bind in the click event of each matching element processing function.

[data],fnString,FunctionV1.4.3

##data:click([Data], fn ) can be passed in data for function fn to process.

fn: The handler function bound in the click event of each matching element.

Example

Description:

Trigger click events for all paragraphs in the page

jQuery code:
$("p").click();
Copy after login
Description:

Hide all paragraphs in the page after clicking.

jQuery code:
$("p").click( function () { $(this).hide(); });
Copy after login
2, onclick event (html api)

##onclickSummary: onclick is the event syntax of html, used in tags
Mouse click A certain object


The click event is a method in jquery, in js Use the execution result processing of defined events in


Recommended related courses:

jQuery video tutorial


##HTML video Tutorial

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

Related labels:
source:csdn.net
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template