DOM 이란?

소바·2022년 8월 16일
0

what is a DOM?

If we want our web site to be interactive, when a user clicks on a button, we'll need to respond to that by changing the content or the appearnace of our web site.

But once our web site is live on the Internet, we can't sit there and wait for the user to click on things on our web site and then update the HTML and CSS code, and then reload their web page

That's, that's impossible.

Now this is the problem that the DOM or the Document Object Model solves.

How can we solve this problem ?

-> DOM tree - select and manipulate

Now the task of converting an HTML file into the DOM is done by the browser when you load up the web page. And what it does is that it turns each of these elements and their associated

data into a tree structure with a whole bunch of objects that you can select and manipulate.

Properties vs Methods

you can see that our objects inside the DOM can have properties and methods

properties describe something about the object
methods are the things that the object can do.

Get property vs Set property

we can use Javascript to manipulate our objects

we can say car.color; to get the value of the property. So this is called a getter.

this is called setting a property. And you can see that the difference between setting a property whether if we assign a value to it with an equal sign.

call methods

if we call the method drive on the object car, It will start moving. this is when we call a method on our object. in this case, drive is a method, because it's associated with the car object.

we able to tap into some of its properties to get it and set it as well as use some of its methods to get it to do things.

They're essentially a function that the object can do all have a set of parentheses that allow you to potentially give it an input if needed.

출처 : 유데미 강좌 (Dr. Angela Yu Developer and Lead Instructor)

profile
소바보이

0개의 댓글