Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialfisnik poroshtica
14,154 Pointswhat does mean this?
what does mean "evt" inside this function:
$('form').submit(function(evt) {
});
2 Answers
Michael Liendo
15,326 Pointsevt
stands for "event" and is often written as just "e" . The argument gets assigned as parameter every time an event happens ie. click, toggle, hover, submit etc.
Depending on the event, there's certain methods that you can trigger. Probably the most common, is in the case of a for being submitted, such as above.
$('form').submit(function(evt) {
evt.preventDefault();
})
This is most common because without it, the form would submit, causing a refresh of the page--when, for example, you'd really want the form to submit to causing that information to update some fields on the page.
Jesus Mendoza
23,289 PointsHey Fisnik,
Everytime an event is triggered an object is passed to the event handler (in this case the event handler is the callback function inside the submit method and the object is the evt parameter).
evt (you can call it whatever you want) is the event object that comes when the click (or any other) event is fired. It has all the information about the event that just happened; like the type of event, who triggered, etc.
In this case the evt object will have information about the form and the submit event.
Good luck!
fisnik poroshtica
14,154 Pointsthank you
fisnik poroshtica
14,154 Pointsfisnik poroshtica
14,154 Pointsthank you