text
stringlengths
1
81
start
float64
0
10.1k
duration
float64
0
24.9
selector and tries to find the button as
1,893.21
4.08
it turns out this is a bit of the quirk
1,895.49
3.09
of the way the browser is going to work
1,897.29
3.09
but if the browser is running our code
1,898.58
3.66
from top to bottom just reading it from
1,900.38
4.08
line one on and on then it's going to
1,902.24
4.68
get to line 18 where I said document
1,904.46
4.32
query selector button onclick equals
1,906.92
4.11
count and it's going to try and find a
1,908.78
4.65
button on line 18 but the button doesn't
1,911.03
5.01
show up in my HTML page until much
1,913.43
4.8
further down in the page so at this
1,916.04
3.75
point when we get to this line of
1,918.23
3.57
JavaScript javascript is looking for the
1,919.79
4.29
button but the Dom the body of the page
1,921.8
4.65
hasn't finished loading yet the content
1,924.08
4.56
of the Dom has not yet loaded and as a
1,926.45
4.35
result we're not able to find this
1,928.64
4.08
button so how do we solve this problem
1,930.8
3.6
how do we get it so we actually are able
1,932.72
3.87
to like ask for the button and actually
1,934.4
3.81
get the button well it turns out there
1,936.59
2.97
are a couple of strategies we could use
1,938.21
4.02
one would be take the script tag and go
1,939.56
4.56
ahead and just move it to the bottom
1,942.23
3.84
section of the body so that after we've
1,944.12
3.15
already defined the button that says
1,946.07
3
count then we have the script tag that
1,947.27
3.54
then says alright go ahead and now find
1,949.07
3.33
the button and now we'll be able to find
1,950.81
3.75
it it turns out another way and perhaps
1,952.4
5.34
a more common way is to instead add yet
1,954.56
5.52
another event listener and we're gonna
1,957.74
3.96
add an event listener not to the button
1,960.08
4.11
but to the entire document where
1,961.7
4.32
document is a variable built into this
1,964.19
3.42
JavaScript that we have access to on the
1,966.02
3.87
web page that just refers to this entire
1,967.61
4.56
web document where I've used document
1,969.89
4.44
query selector already to look through
1,972.17
3.75
the whole web document trying to find a
1,974.33
3.63
button or trying to find an h1 tag for
1,975.92
4.77
example but I can also add an event
1,977.96
5.64
listener to the document itself and in
1,980.69
5.19
order to do that I can say document dot
1,983.6
6.66
add event listener and when I call add
1,985.88
6.12
event listener and I can do this on any
1,990.26
3.69
HTML element not just the document but I
1,992
3.66
could run this function on a button or
1,993.95
3.48
on an h1 element or any other HTML
1,995.66
3.72
element add event listener will
1,997.43
4.47
generally take two arguments where the
1,999.38
5.04
first is what event I want to listen for
2,001.9
4.35
the event could be something like click
2,004.42
3.69
when I click on the document it could be
2,006.25
4.44
something like when I scroll through a
2,008.11
4.53
page for example but with the event I'm
2,010.69
3.39
going to listen for is a particularly
2,012.64
4.17
special event called Dom content loaded
2,014.08
6.54
and the Dom content loaded event is an
2,016.81
5.01
event that is going to be
2,020.62
3.75
hired or triggered when the Dom the
2,021.82
4.11
document object model the structure of
2,024.37
3.84
the page is done loading when all of the
2,025.93
3.48
elements on the page are done loading
2,028.21
3.63
the Dom content has been loaded and then
2,029.41
4.98
if I attach an event listener to it you
2,031.84
4.35
know run whatever code I want to run
2,034.39
4.23
that should only run after the Dom is
2,036.19
4.59
fully loaded after all of the content on
2,038.62
5.04
the page has then been loaded and the
2,040.78
5.28
second argument to an event listener is
2,043.66
5.73
what function should run once the event
2,046.06
4.86
actually happens when the Dom content
2,049.39
3.72
loaded does happen so I could pass in
2,050.92
4.2
the name of a function if I had the name
2,053.11
3.87
of a function that I wanted to pass in
2,055.12
4.32
but alternatively JavaScript allows me
2,056.98
5.31
to just directly write a function here
2,059.44
5.28
in the argument to add event listener I
2,062.29
4.92
can just say function and then a set of
2,064.72
3.84
parentheses to mean the function doesn't
2,067.21
3.69
take any input and then in curly braces
2,068.56
4.89
I can include the body of the function
2,070.9
6.39
right here as the second argument to add
2,073.45
5.4
event listener and this is a little bit
2,077.29
2.97
of tricky syntax to wrap your mind
2,078.85
2.4
around if you've never seen it before
2,080.26
2.85
but the big-picture way to think of it
2,081.25
3.9
is add event listener takes two
2,083.11
4.44
arguments one is the event the second is
2,085.15
4.53
the function so here first is the event
2,087.55
4.2
Dom content loaded and the second
2,089.68
4.8
argument is a function and I declare the
2,091.75
4.11
function same as before just using
2,094.48
3.3
function I haven't given the function a
2,095.86
4.05
name because strictly speaking it
2,097.78
3.18
doesn't need a name
2,099.91
2.31
I'm never going to refer to this
2,100.96
3.12
function by name so it is what we might
2,102.22
3.99