Preview

15 - JavaScript Events

 1. JavaScript's interaction with HTML is handled through ______ that occur when the user or the browser manipulates a page
Note: It is important to note that web events are not part of the core JavaScript language — they are defined as part of the JavaScript APIs built into the browser.

  variables

  scripts

  events

  clicks

 2. Which of the following is an example of an HTML event?
An HTML web page has finished loading
An HTML input field was changed
An HTML button was clicked

  An HTML button was clicked

  An Html page web page has finished loading

  All of the items on the list are valid events

  None of the items on the list are valid events

 3. Each available event has an ________________, which is a block of code (usually a user-defined JavaScript function) that will be run when the event fires.

  event variable

  event method

  event handler

  addler

 4. HTML allows ________________________, with JavaScript code, to be added to HTML elements
With single quotes:

<element event='some JavaScript'>
With double quotes:

<element event="some JavaScript">

  property methods

  method handlers

  script properties

  event handler attributes

 5. Which statement describes what is happening in this code?
<!DOCTYPE html>
<html>
<body>

<button onclick="document.getElementById('demo').innerHTML=Date()">The time is?</button>

<p id="demo"></p>

</body>
</html>

  a button element (with code) is added to an onclick event

  an onclick attribute (with code), is added to a button element:

  an onclick property (without code) is added to a text element

  an onButton property (with code), is added to an onclick event

 6. The following list shows some very common HTML events
Event	        Description
=======         ===========
onchange	An HTML element has been changed
onclick	        The user clicks an HTML element
onmouseover	The user moves the mouse over an HTML element
onmouseout	The user moves the mouse away from an HTML element
onkeydown	The user pushes a keyboard key
onload	        The browser has finished loading the page

  FALSE

  TRUE

 7. The onsubmit event is used in this example. Here we are calling the ____________before submitting form data to the web server.

  submit function

  input type submit function

  form method

  validation function

 8. Match the event to the description
Triggers when a mouse button is released

  onmouseup

  onfocus

  onloadstart

  onselect

 9. Match the event to the description
Triggers when an element is selected

  onmouseup

  onloadstart

  onfocus

  onselect

 10. If you want to target a touch-enabled device like an iPad, iPhone, Android tablet or phone, etc, then you need the _______________.
These events are touchstart, touchend, touchcancel, touchleave, touchmove.

  screen events

  mouse events

  None of these answers are valid

  touch events