js-lib

Monday, February 28, 2011

JavaScript101 - Week 5 (Track 1)

  1. Why is it better to use either trickling or bubbling of events? Why not just give the event to the node on which it was invoked?
  2. Let's say there is an event you want to handle for dozens of similar elements on the page. Without bubbling, you would have to wire the same event handler to every single one of those elements. It's better to enclose the elemements in a parent node and assign the event handler to the parent; the handler will then respond to the event as it bubbles up from each child element.

  3. Can you think of one situation where you would want to prevent the browser from submitting a form after a user has clicked on the 'submit' button? How would you achieve this?
  4. Form data should be validated on the client side before submitting is allowed. I would write a validateForm() function and set the sumit button as follows: onclick="return validateForm()"


Enter how many numbers you want to add
(between 2 and 10):


 

No comments: