/    Sign up×
Community /Pin to ProfileBookmark

JavaScript event (e)

Hi,
I am trying to figure out what event (e) means.
The event the I mostly use in functions , idk if can be used anywhere else. Ex: function(e) {}.
I know only a bit about it but I don;t necessary know when to use it, I kinda guess it right now.
I tried to look only but I can find video and article only for event listener.
Can you give me a good article about it if there is any?

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@daveyerwinJun 25.2019 — the event object is automatically passed to the event handlers

the letter e has no significance it is used by convention

it can be any identifier

the event object contains many properties and methods of the event

https://developer.mozilla.org/en-US/docs/Web/API/Event

here is an example of two that are widely used ...

> <form action="http://msn.com">

> <button value=one>first </button>

> </form>

> <div id=test>

> <button value=one>first </button>

> <button value=two>second </button>

> <button third value=three>third </button>

> <form action="http://msn.com">

> <button value=formSubmit>submit </button>

> </form>

> </div>

> <script>

> test.onclick=function(eventObj){

> eventObj.preventDefault();

> alert(eventObj.target.value)

> }

> </script>
Copy linkTweet thisAlerts:
@SempervivumJun 25.2019 — MDN commonly is a good resource:

https://developer.mozilla.org/en-US/docs/Web/API/Event

One property that is used often ist target:

https://developer.mozilla.org/en-US/docs/Web/API/Event/target

It specifies the element where the event was triggered, e. g. by click.

A method that is used often ist preventDefault():

https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault

It supresses the default action of the browser. E. g. for a link this is opening the page that is specified in the href attribute. If preventDefault is called on the event. the browser will not do this.
Copy linkTweet thisAlerts:
@psimiyuJun 25.2019 — Hi all, kindly help me resolve the discussion Ive just posted under heading html css FAQS
Copy linkTweet thisAlerts:
@SempervivumJun 25.2019 — @psimiyu#1605364 Please don't hijack other threads in order to attract interest for your own one!
×

Success!

Help @codyhill spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 4.26,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...