Difference and Usage Analysis of Click and OnClick in JavaScript

This example tells the difference and usage of Click and OnClick in JavaScript in JavaScript. Share to you for your reference, specifically:

Native JavaScript Click The elaboration in W3C is a Dom Button object, and it is also an HTML DOM Click () method, which simulates on the button. A mouse click.

The Button object represents a button in the HTML document. Button elements do not have a default behavior, but must have an onclick event handle for use.

Syntax:

ButtonObject.Click ()

Function ClickButton () {document. getElementByid (‘Button1’). Click ()} Function Alertmsg () {Alert (“Button 1 Was Clicked!”)}
         OnClick  is an event, an EVENT object. JavaScript objects for this event: Button, Document, Checkbox, Link, Radio, Reset, Submit   HTML Dom Event object, representing the status of the event, such as the element in which the event occurs, the keyboard button, the mouse The position of the mouse button. The event is usually used in conjunction with the function, and the function will not be executed before the event!   
FIELD1:

Field2: Click the button below to copy the contents of Field1 to Field2:

Copy Text

     


The previous Click is a method, and OnClick is an event.
1. The event is generally started at the beginning;

2. Method is to call the statement directly, ie Display call;

3. Event does not need to be called, but must write a function by the programmer and assign the function to the corresponding event, and its call is in the corresponding event. Trigger. [Tell the browser what to do when you click] So the call order is: First, the second event is first.

An article can be extended:

1. $ (“”). Click

and

Onclick [ Difference example introduction

Address: https://www.jb51.net/Article/55650.htm

2. Learn jQuery (5) jQuery events and event objects from zero

Address: https://www.jb51.net/Article/26331.htm

3. JQuery Dynamic Removing and Increasing OnClick Attributes Detailed

Address: https://www.jb51.net /Article/141648.htm

JavaScript event instructions for JavaScript event instructions

JavaScriptParts and function descriptions : http://tools.jb51.net/table/javascript_event More about JavaScript related content, readers, interested, can view this site: "JavaScript event related operations Skills Daquan, "JavaScript Page Element Skill Summary", "JavaScript Operation DOM Skill Summary", "JavaScript Finding Algorithm Skills Summary", "JavaScript Data Structure and Algorithm Skills Summary", "JavaScript Has Algorithm and Skills Summary" and "JavaScript Error and debugging skill summary "
I hope this article will help you JavaScript programming.

© Copyright Notice
THE END
Just support it if you like
like0
share
comment Grab the couch

Please log in to comment