02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Interacting with the DOM

This is the first time we actively are interacting with the dom in this example we will be tweaking the html and css via code.

Video Transcript

00:00All right, so the next step for us is we wanna get our box.
00:03So I'm gonna set our box and again,
00:04we're gonna approach that document that we've met before.
00:07Now we're gonna start playing with that.
00:09Whoops, did I write it incorrectly?
00:10Doc, you meant?
00:13And we wanna get element by ID
00:16and we wanna make sure that we know what the ID is.
00:18So we're gonna come up here into our HTML again
00:22and we're gonna find our boxes
00:25and they are right here.
00:26So we have early date, mid date, last date.
00:31So I wanna go back into our code
00:32and we'll put this all the way in the beginning here
00:35before even we use our if statement
00:37so we could have access to those elements.
00:39And I'm just going to really quickly
00:42create those three variables.
00:45So we're using the ID
00:47and then we're just creating a variable
00:48with a name that is similar to the name inside of the ID.
00:51So we have three of them.
00:53So let me just create three of them
00:56and we'll go back into our source code,
00:57we'll get our mid date.
01:00And that will be our mid date.
01:03And last but not least is our last date.
01:09And oopsie, big oopsie, you'll notice
01:11that we have here a couple of mistakes that I wanna fix.
01:13So I just noticed them.
01:14One of them is that when we're creating our early date,
01:17I actually copied our early date again.
01:19So what I wanna do is I actually wanna make sure
01:21that we're actually calling the properties of the late date
01:24because if not, we're just gonna be resetting
01:26our early date again.
01:27So that was a big no-no.
01:29Next mistake that I noticed
01:30is just copying pasting quickly
01:33is that our last date and our last date,
01:34we actually created two times the same variable,
01:37aka we deleted this variable
01:39and put inside of it this variable instead.
01:42So what I wanna do is I wanna just start off
01:43all these variables and maybe we'll give them a name
01:45and we'll start them off with div early date,
01:51div mid date, and we'll do a div last date.
01:58That way we'll make sure
01:59that they're completely different
02:00and we won't have issues of overlapping each other.
02:03All right, so now we could delete this box.
02:05And now that we know that we're supposedly always true,
02:07we're in the late date,
02:08what we actually wanna do is we wanna go to the early date
02:11and we wanna go to the middle date.
02:13And this is how it works.
02:14Basically, we wanna go into our early date
02:16and we wanna actually change our class itself.
02:19So I'm gonna search in my options
02:20because I'm in Dreamweaver,
02:21I could just basically search for the property that I need
02:24and here we go, we have our class name.
02:26And our class name is a string property
02:29that I could then change it if I want to.
02:31I don't wanna change it.
02:32What I actually wanna do is I wanna add to it.
02:34Because I wanna add to it,
02:35what I'm gonna do is I'm gonna type plus equals
02:37and after I type plus equals,
02:39I could then say what I wanna do to it.
02:41What I actually wanna do is put a space
02:42and then write transparent.
02:46What that will do is it will make
02:48our early date transparent.
02:49So if we go into our design,
02:51we'll see that now our early bird,
02:53because we're in that if statement, became transparent.
02:56Because we have a class in our CSS
02:58that is called transparent.
03:00So we wanna do the same thing O2 to our mid date
03:03because now we're in the late date.
03:06So if we go back to the design, the exact same thing,
03:08all I did is I made the middle date as well transparent.
03:12So now that we know that this works,
03:13we could comment out this true area
03:17that we were just using for testing.

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!