PrepAway - Latest Free Exam Questions & Answers

You need to modify the webpage to invoke the JavaScript function named someEvent()

You troubleshoot a webpage that contains the following HTML markup: (Line numbers are included
for reference only.)

The webpage also contains the following JavaScript function named someEvent() that is declared in
the HEAD section of the HTML:

Function someEvent() {
Alert('someEvent fired!');
}

The JavaScript function named someEvent() must run only when the user clicks the DIV element, not
the INPUT elements.
You need to modify the webpage to invoke the JavaScript function named someEvent().
What should you do? (Each correct answer presents a complete solution. Choose two.)

PrepAway - Latest Free Exam Questions & Answers

A.
Option A

B.
Option B

C.
Option C

D.
Option D

17 Comments on “You need to modify the webpage to invoke the JavaScript function named someEvent()

  1. rik says:

    At first I thought A and C were correct, simply because B and D are clearly wrong. Then I looked it up, and now I’m positive. (From http://javascript.info/tutorial/bubbling-and-capturing)

    When you click an html element, its click event fires. This event then ‘bubbles up’ to its first parent, firing the parents click event, and then the next parent all the way up to . (If no handler is defined for the click event of any of the element or parents, nothing happens).
    The element that started the event bubbling (the element that was clicked) can be targeted with ‘event.srcElement’ (for internet explorer) or ‘event.target’ (all other browsers).

    A:
    A handler may decide that the event is fully processed and stop the bubbling. For all browsers except IE <9 this is done with ‘event.stopPropagation’. For IE<9 it is event.cancelBubble.

    C:
    By using ‘this’ on the parent DIV, ‘el’ represents the parent DIV element. So only if the element that was clicked === the parent div, the alert will pop up.




    0



    0
  2. Marsi says:

    We all agree that A is correct.
    I did try B and it does not work. D is clearly wrong, so it leaves C which I believe must be poorly coded as mentioned above but it should be the right answer.




    0



    0

Leave a Reply