JavaScript Events

Events are the users’ actions, a web page can respond to, such as,

  • Loading a page,
  • Mouse click,
  • Keystroke,
  • Click on submit button,
  • Pressing a key,
  • Closing a window, etc.

In this lesson, we will learn how to work with JavaScript events.

JavaScript onclick event

This event fires when a user clicks the mouse. On the click of the left mouse button, an HTML element gets clicked i.e., a function gets called. The onclick attribute is used for this.

Let us see an example to implement the onclick event in JavaScript:

Output

JavaScript onclick event

Click the Click Me!!! Button to fire an event:

JavaScript onclick event output

JavaScript ondblclick event

This event fires when a user double-clicks the mouse. On the double-click of the left mouse button, an HTML element gets clicked twice. The ondblclick attribute is used for this.

Let us see an example. We have considered the same example discussed above. The attribute ondblclick is set for the double click event:

Output

JavaScript ondblclick event

Click the Double Click Me!!! Button twice to fire an event:

JavaScript ondblclick event output

JavaScript onmouseover event

This event fires when the mouse pointer is kept over an HTML element. The onmouseover attribute is used for this. Let us see an example. We have considered the same example discussed above:

Output

JavaScript onmouseover event

Keep the mouse cursor on the button Keep the cursor here to fire an event:

JavaScript onmouseover event output

JavaScript Operators
JavaScript Objects
Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Post A Comment

Events

Events

IDigitalpreneur - Webinar

Learn Python for Data Science Webinar

Speaker @ IDigitalpreneur, Delhi
Technologies: Python, SQL, NoSQL
Date: 24th Dec, 2023 | 6 pm – 7 pm

YouTube - Creators (Delhi)

YouTube Creator Collective Delhi

YouTube Creator Collective Event
Location: Roseate House, Aerocity, Delhi
Date: 10th Dec, 2023 | 4 pm – 7 pm

GeeksforGeeks - Webinar

Geekforgeeks Webinar

Speaker @ GeekforGeeks, Noida
Technologies: Python, Data Science
Date: 18th Dec, 2022 | 7 pm – 8 pm

IMS Noida - Seminar

IMS Noida Seminar Studyopedia

Speaker @ IMS, Noida
Technologies: Python, Data Science
Date: 12th Oct, 2022 | 10 am

GeeksforGeeks - Webinar

Bootstrap GeekforGeeks Amit Diwan

Speaker @ GeekforGeeks, Noida
Technologies: Bootstrap
Date: 22nd June, 2022 | 1pm

IASRI Delhi - Webinar

IASRI ICAR Data Science Webinar

Speaker @ IASRI, Pusa, Delhi
Technologies: MySQL, MongoDB
Date: 25th Feb, 2022 | 2pm – 5pm

GNIM (GGSIPU) - Webinar

GNIM Punjabi Bagh Amit Diwan Studyopedia

Speaker @ GNIM, Punjabi Bagh, Delhi
Technologies: Python
Date: 18th Feb, 2022 | 12pm

LIVE Webinar

Studyopedia Editorial Staff
Studyopedia Editorial Staff
[email protected]

We work to create programming tutorials for all.

No Comments

Sorry, the comment form is closed at this time.

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading