Web Development with jQuery®

(Elliott) #1

(^488) ❘ APPENDIX A EXERCISE ANSWERS
bapp01.indd 02/18/2015 Page 488
$('#myScroller').scrollTop(0);



  1. Answers will vary but should describe calculating the element’s scrollHeight and using an
    arbitrary value expected to be larger than the scrollHeight.








CHAPTER 11



  1. Depending on the browser, you use the –webkit-user-drag CSS property with a value of ele-
    ment for older versions of Webkit-based browsers such as Safari and Chrome. You use the
    draggable HTML attribute, which is the offi cial method sanctioned by the HTML5 specifi ca-
    tion and supported by all modern browsers. Or you can use the dragDrop() method on the
    element’s DOM object, which enables drag and drop in IE5 through IE8.

  2. The drag events in the order that they fi re are dragstart, drag, and dragend.

  3. The drop events in the order that they fi re are dragenter, dragover, drop, and dragleave.

  4. You look for event.originalEvent.dataTransfer.files within the drop event. Without using
    jQuery to attach the event listener, you look for event.dataTransfer.files within the drop
    event.

  5. A base64-encoded data URI is assigned to the value of the src attribute of an
    element. The data URI can also be used with the CSS background and background-image
    properties.

  6. The progress and load events can be attached to the upload property of an XMLHttpRequest
    object to monitor the upload progress of fi les.

  7. The event.lengthComputable, event.loaded, and event.total properties.

  8. First, you instantiate the FormData object; the instantiated object is stored in a variable. Then
    use the append() method on the instantiated object to create custom POST variables.

  9. You attach a load event to the XMLHttpRequest object. This event is fi red when the upload is
    successful.


CHAPTER 12



  1. draggable()

  2. Any syntactically correct program, which implements the following (or similar enough to the
    following):


draggable({
helper : 'clone',
opacity : 0.5
});

http://www.it-ebooks.info

Free download pdf