Quiz
- Are these quizzes graded for correctness or completeness? I feel like sometimes there are trick questions, which trip me up.
I'm sorry that you feel they are tricky. I don't intend them to be tricky. Please talk to me about this.
- I am still a bit confused about the concept of API
It's an interface between parts of a program, whether you (or your team) wrote both parts or whether one part is a library that other folks created. When you do
import random
in Python or Java, that's an API. - I’m still confused about what the DOM is conceptually, and how does it relate to HTML? They seem quite similar.
The DOM is an API that allows JS to dynamically modify the page, including the HTML and the CSS. So, yeah, they are similar. But HTML was originally intended to be written by humans, and so it was static. The DOM allows it to be dynamic.
- I’m having difficulty loading jQuery - should I be putting the code somewhere other than my browser console? I keep getting a SyntaxError.
There is a way to load it dynamically, but I always load it with a
script
tag in the HTML page. - Why use JQuery when there is already Javascript? Is it when there's so little Javascript neede for a file it doesn't make sense to create another JS file?
You are right that JQuery is not strictly necessary. But we use libraries because they make things easier. JQuery makes working with the DOM a little easier.
Avoiding loading extra files can be part of the decision, but programmer effort is important as well.
- I still don't really understand H3 events. Can you explain why we use them and hos they are helpful?
H3 events aren't a thing. That was just a section header that I used as an example. Let's look at it together: click example
- When do you use a #before an id? / Difference between adding # to the name and without #. Is # for element and no # like "P" is for the known ones?
When we give something ID, we can refer to the thing using the hashtag character and the id.
- I would like to know more about the hashtags used.
They can also be used in URLs, to go directly to a location on the page
- For JQuery methods, what are the differences between attr and CSS, and what are the differences between text and HTML.
Excellent and subtle questions!
attr
allows you to change any attribute, such as thesrc
of an image (useful for image swaps).css
allows a more structured way to modify thestyle
attribute.text
andhtml
are very similar. They are identical for text, but differ in how they handle HTML code.Using the
html()
method is good when the HTML is not trustworthy, as with user-contributed content. - Could we go over other examples of DOM events
Here's a list of some common events which links to a longer list. We'll stick with
click
for a while and introduce others when needed - A clarifying question: is an "event handler" just a function that deals with user-initiated events?
Yes.
- Regarding the part about “The Click Method”, it mentions the browser will invoke the function when the event happens. Does this just mean that the function doesn’t do anything until the header is being clicked on (the event happening), and that's when the function is invoked and runs to change it to a random color? Am I understanding this correctly?
Correct!
- how the find command works, I am very unsure about the syntax of that
The
find
method is most useful when searching a subtree: - Probably a bit more on implementing chaining
Sure. Just have the method return the object. Amazing
- No. I think I just need more practice of JQuery
Don't we all?
- How did you create the plugin? Is that something that we might be able to learn in this class as well?
/ Plugins
I won't teach that in class, but I'm happy to talk in OH.
- I'm curious about the challenge question! Couldn't figure it out, but interested.
Let's talk in OH
- None! :) / I think I got everything!
Great!