Home  >  Article  >  Web Front-end  >  The difference between click event and onclick event

The difference between click event and onclick event

little bottle
little bottleforward
2019-04-16 09:41:224886browse

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();
Description:

Hide all paragraphs in the page after clicking.

jQuery code:
$("p").click( function () { $(this).hide(); });
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!

Statement:
This article is reproduced at:csdn.net. If there is any infringement, please contact admin@php.cn delete