DOM (Document Object Model)

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

How can you include an entire javascript file from HTML? And why would you want to do that?

using the src attribute in the script tag is how you call a specific javascript file. <script src="placeholder.js"></script> You want to do this because the alternative would be to place all the jode in that file inside the script tags. here is an example: <script src="code/hello.js"></script>

What is a parser? What does it mean to parse?

" a program that reads a piece of text and produces a data structure that reflects the structure of the program contained in that text."

What is polling?

Constantly checking whether a key was pressed or not and remembering to check that key or mouse click.

Why would we want to use stopPropagation() and preventDefault() .

With submit buttons on forms. Submit the form with the data, but the browser will navigate to that forms action page, but if you want the browser to not navigate here you can use it here. You can disable links. For button clicks, you can use it to prevent multiples clicks to a button or if a button is located inside another clickable element but you only want the event to register for the button but not the parent element.

Can attributes contain javascript?

Yes here is an example of one <button onclick="alert('Boom!');">DO NOT PRESS</button>

What is a block element?

paragraphs (<p>) or headings (<h1>), take up the whole width of the document and are rendered on separate lines.

How are elements represented in HTML and what are they?

Elements are represented by tags < > and they are objects in the DOM.

What is the disadvantage of using innerHTML over textContent

<li> will be interpreted by innerHTML (it will parse it). As well, there are security concerns. People can inject html onto the html content.

How do you include javascript in HTML?

<script></script>

Do event handler functions receive an argument?

Yes they receive an event object, which gives us more information. This information can be accessed by its property.

Do browser event handlers are registered in specific contexts?

Yes, because each DOM element has its own addEventListener method including the whole window itself.

When working with a collection of elements can you use for loops and treat them like arrays?

No, while you can specify using brackets [] you can not treat theme exactly like arrays and use for loops.

What is the DOM?

The document object model. DOM is the interface that the browser provides you to access all that stuff through JavaScript. It's a collection of methods and properties that you can use to get into each of those elements. When you're working in CSS to style your pages, you're also working with the Document Object Model through a different interface. So when you write selectors using IDs, classes, tag names, all that sort of things, it's a similar interface. So, the DOM has a lot of built-in methods. The one that you'll probably see the most often is called getElementById, which is a method, built into the global document object.

DOM node object have a nodeType property. What kind of code identifies the type of node?

There is a numeric code. A regular element have the value of 1which is also defined as the constant property document.ELEMENT_NODE. Text nodes is represented with eh value of 3 and comments have the value of 8.

What is the difference when search elements by tag and elements by id? And when we assign this/these elements by to variable how can we interact with this variable?

When searching for elements by tag, we get a collection of elements. While searching for elements by id we only get one element back because each element should only have one id. As a result when making changes to a variable that was assigned by a tag, you can not because it is a collection and JS does not allow this.When making changes to a variable that has been assigned according to i.d. you can make changes because only one element exists in that variable.

What does it mean to propagate?

To propagate means that a child node registers a click or some action and it goes up or outwards to parent nodes/elements that also have event handlers.

How can you specify a type of event with an addEventListener and an event?

You can use the target property of the event. Target returns the element that triggered the event.

What is an inline element?

links (<a>) or the <strong> element used in the previous example, are rendered on the same line with their surrounding text.


संबंधित स्टडी सेट्स

Sage Vantage MARK3330 Business Ethics Chapter 11 Test

View Set

Accounting and the 3 Financial Statements

View Set

Psych 2300 Research Methods Exam 1

View Set