JavaScript Week 11 PDF
Document Details
Uploaded by BetterThanExpectedLearning9144
Yeungjin University
Tags
Summary
This document contains practice questions on various JavaScript events. The document covers mouse events (click, mouse down, mouse up, etc.), and keyboard events (key press, key down, key up).
Full Transcript
JAVASCRIPT WEEK 11 1. This method attaches an event handler function to an HTML element and is executed when the user clicks on the HTML element. The above description is true to what mouse event methods? a. Mouseenter() b. Mouseleave() c. Click() \# d. Dblclick() 2. This method...
JAVASCRIPT WEEK 11 1. This method attaches an event handler function to an HTML element and is executed when the user clicks on the HTML element. The above description is true to what mouse event methods? a. Mouseenter() b. Mouseleave() c. Click() \# d. Dblclick() 2. This method attaches an event handler function to an HTML element and is executed when the left, middle or right mouse button is pressed down, while the mouse is over the HTML element. The above statement is true to what mouse event method? a. Mouseenter() b. Mouseleave() c. Mousedown() \# d. Mouseup() 3. This method attaches an event handler function to an HTML element and is executed when the left, middle or right mouse buttn is released, while the mouse is over the HTML element. The above statement describes what mouse event method? a. Mouseenter() b. Mouseleave() c. Mousedown() d. Mouseup() \# 4. The event.which property is use for what? a. Return which keyboard key was pressed for the event. b. Return which mouse button was pressed for the event. c. Return which keyboard key or mouse button was pressed for the event. \# d. None of the above 5. What keyboard event is described by this statement: the key is pressed down? a. Keydown b. Keypress \# c. Key up d. Keyword 6. What keyboard event is described by this statement: the key is released? a. Keydown b. Keypress c. Keyup \# d. Keyword 7. What is the correct syntax that triggers the key down event for the selected elements? a. \$(selector).keydown() \# b. \$(selector).keydown(function) c. \$(selector).keypress() d. \$(selector).keypress(function) 8. What is the correct syntax to use for an event that occurs when a keyboard key is released and there is a function attached? a. \$(selector).keydown() b. \$(selector).keydown(function) c. \$(selector).keyup() d. \$(selector).keyup(function) \# 9. In jQuery, most DOM events have an equivalent jQuery method. You wanted to assign a click event to all paragraphs on a page and wanted to define what should happen when the event fires. What is the sample syntax to use? a. \$("p").click(); b. \$("p").click(function(){ // action goes here!! }); \# c. \$(selector).click() d. \$(selector).click(function(){ //action goes here!!}); 10. This method is often used together with the blur() method. a. focus() method \# b. change() method c. submit() method d. load() method 11. What is the syntax for focus() method? a. \$(selector).focus() or \$(selector).focus(function) \# b. \$(selector).blur() or \$(selector).blur(function) c. \$(selector).submit() or \$(selector).submit(function) d. \$(selector).change() or \$(selector).change(function) 12. This event occurs when an element loses focus and is often used together with focus() method. a. Focus event b. Blur event \# c. Change event d. Load event 13. This event can only be used on \ elements and it occurs when it is submitted. a. submit() Method \# b. \$(selector).submit() c. \$(selector).submit(function) d. \$(document).ready(function(){ \$("form").submit(function(){ alert("Submitted"); }); }); 14. Which statement is false for change() method? a. The event occurs when the value of an element has been changed. b. Only works on \, \ and \ elements. c. For select menus, the change event occurs when an option is selected. d. \$(change).selector() \# 15. Which statement is true about change() method? a. For text fields or text areas, the change event occurs when the field loses focus after the content has been changed. \# b. This event works with elements associated with a URL and the window object. c. This event occurs when a specified element has been loaded. d. All of the above. 16. This event occurs when the user navigates away from the page. a. load() method b. resize() method c. scroll() method d. unload() method \# 17. The following are triggers to unload event except: a. A link to leave the page is clicked or a new URL is typed in the address bar b. The forward or back buttons are used c. The browser window is closed, and the page is reloaded d. The unload event works differently in different browsers \# 18. The following statement pertains to resize() method except: a. Resize event occurs when the browser window changes size b. The syntax to trigger the resize event is \$(selector).resize() c. To attach function to resize event use \$(selector).resize(function) d. Often used together with scroll() method. \# 19. The following statements is all about scroll() method except: a. The scroll events occur when user scrolls in the specified element. b. The scroll event works for all scrollable elements and window object (window browser). c. The scroll() method triggers scroll event. d. Needs to test this method in all browsers before using. \# 20. This method attaches one or more event handlers for the selected elements and child elements. a. resize() method b. scroll() method c. unload() method d. on() method \# 21. As of jQuery version 1.7 this replaces the bind(), live() and delegate() methods. This method brings a lot of consistency to the API and is recommended to simplify the jQuery code base. What method is this? a. resize() method b. scroll() method c. unload() method d. on() method \# 22. Which of the following statements is unacceptable for on()method. a. Event handlers attached using the on() method will work for both current and future elements. b. To remove event handlers, use the on() method. \# c. To attach an event that only runs once and then removes itself, use the on() method. d. None of the above.