Answer to Lab 8

Emma Bostian and Nicholas Varlese

Question 1: How is the layering of elements determined.

Layering is determined by the order in which the elements are created. Elements that are created last overlap elements that were created first.



Question 2: Explain what "this" really means.

This is used to refer to the object which the function was called on.



Question 3: Explain how jQuery can apply four mouseenter events with one method call.

JQuery can apply four mouseenter events by using "this" to refer to the paragraph which the function mouseenter was called upon.



Question 4: Explain in detail how I am independently keeping track of the state of each slider and why it would be a mistake to use JavaScript variables to remember each slider's state.

We are independently keeping track of the state of each slider by using this to select the container, and then grabbing this's children to select each individual slider. It would be a mistake to use JavaScript variables to remember each slider's state because you would need a plethora of "if/else" statements to keep track of each individual slider's and container's states.



Question 5: Consider how you would implement this in pure JavaScript without jQuery. Explain why jQuery is superior.

You could implement this with JavaScript by using if/else statements to determine what was entered into the text boxes when the submit button was pressed. If the input was null, you would print an error message. Else, you would use a JavaScript variable to keep track of the submitted text, and print the value to the canvas.



Question 6: What is the the difference between $("p") and $("< p>"). How do you think jQuery internally handles string parameters to determine a DOM query vs. a DOM element creation.

The first statement creates a variable named "p" where the other statement creates an HTML paragraph option. JQuery handles string parsing to determine whether to create a variable or a DOM object by parsing the string and checking if there is an opening tag (which creates a DOM element). If there is no opening tag after the quotes, it assumes it to be a variable.