text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
selector hello get me the HTML element | 3,013.4 | 6.39 |
whose ID is hello and go ahead and | 3,017.27 | 6.24 |
modify its style property and now inside | 3,019.79 | 6.27 |
of this style object I can modify any of | 3,023.51 | 4.68 |
the CSS style properties one of them for | 3,026.06 | 5.01 |
example is something like color so I can | 3,028.19 | 5.34 |
update the color property and set it | 3,031.07 | 6.87 |
equal to red so here now I'm saying when | 3,033.53 | 6.9 |
you click on the red button go ahead and | 3,037.94 | 4.65 |
run this function and what the function | 3,040.43 | 4.59 |
should do is find the hello element | 3,042.59 | 5.1 |
update it style what part of the style | 3,045.02 | 3.84 |
update its color | 3,047.69 | 3.54 |
what should we update it to we should | 3,048.86 | 5.16 |
update it to red and I'm gonna do the | 3,051.23 | 4.29 |
same thing for the other two buttons as | 3,054.02 | 3.06 |
well and it's pretty similar codes I'm | 3,055.52 | 4.26 |
just going to copy paste copy paste here | 3,057.08 | 3.99 |
I'm gonna have one for changing the | 3,059.78 | 3.27 |
color to blue when I click the blue | 3,061.07 | 3.51 |
button you should change the color to | 3,063.05 | 4.05 |
blue and then we'll do it one more time | 3,064.58 | 5.34 |
change the font color to green when you | 3,067.1 | 4.26 |
click on the green button you should | 3,069.92 | 5.67 |
change the color to green so now when i | 3,071.36 | 6.75 |
refresh the colors wml right now hello | 3,075.59 | 4.11 |
by default it's just in black standard | 3,078.11 | 4.68 |
font color for HTML I click red hello | 3,079.7 | 4.74 |
changes to red I click blue it changes | 3,082.79 | 3.96 |
to blue I click green it changes to | 3,084.44 | 3.78 |
green so depending on what button I | 3,086.75 | 3.72 |
click that triggers some event listener | 3,088.22 | 4.5 |
that's going to then say when the button | 3,090.47 | 4.05 |
is clicked run this function and what | 3,092.72 | 4.2 |
the function does is it grabs this h1 | 3,094.52 | 4.37 |
element the element whose ID is hello | 3,096.92 | 4.679 |
modifies it style updates its color | 3,098.89 | 4.84 |
property to be something like red or | 3,101.599 | 4.801 |
blue or green and that's showing that we | 3,103.73 | 3.57 |
can modify style | 3,106.4 | 2.82 |
in addition and just modifying the | 3,107.3 | 5.519 |
content of the page itself but it turns | 3,109.22 | 5.07 |
out that as you looked at me writing | 3,112.819 | 2.79 |
that code something should have struck | 3,114.29 | 3.69 |
you is probably not optimal design then | 3,115.609 | 4.021 |
in general any time you find yourself | 3,117.98 | 3.3 |
writing the same code again and again | 3,119.63 | 3.209 |
and again especially if your copy | 3,121.28 | 3.45 |
pasting that that is a generally a bad | 3,122.839 | 3.931 |
sign usually a sign that there is some | 3,124.73 | 5.4 |
better way of trying to modify of trying | 3,126.77 | 4.98 |
to implement the behavior that I'm | 3,130.13 | 3.33 |
trying to create and it turns out that | 3,131.75 | 2.91 |
there is and there are a number of ways | 3,133.46 | 4.109 |
that you could do this one way here is | 3,134.66 | 4.439 |
that I might like to consolidate these | 3,137.569 | 4.141 |
three event listeners into just like a | 3,139.099 | 4.831 |
single function that is going to handle | 3,141.71 | 4.77 |
changing the color to whatever the | 3,143.93 | 4.35 |
button says the color should be changed | 3,146.48 | 4.74 |
to but one problem here is that if I | 3,148.28 | 4.74 |
just attach the same event listener to | 3,151.22 | 4.32 |
all three of the buttons it's not going | 3,153.02 | 4.98 |
to be clear to me when I click on the | 3,155.54 | 3.87 |
button how does the button know what | 3,158 | 4.02 |
color we should change the text to and | 3,159.41 | 5.429 |
so to that effect we can add some | 3,162.02 | 5.099 |
additional special attributes to a | 3,164.839 | 4.5 |
particular HTML element that are called | 3,167.119 | 5.131 |
data attributes where a data attribute | 3,169.339 | 5.911 |
is my way of saying that I would like to | 3,172.25 | 5.339 |
associate some data with this particular | 3,175.25 | 4.98 |
h2 what HTML element we're here I can | 3,177.589 | 7.651 |
say data - color equals red data - color | 3,180.23 | 8.67 |
equals blue data - color equals green | 3,185.24 | 5.849 |
data attributes always start with data | 3,188.9 | 4.02 |
followed by a dash and then I can | 3,191.089 | 3.75 |
specify really any name that I want for | 3,192.92 | 3.39 |
some information that I would like to | 3,194.839 | 4.26 |
store about the HTML element and here | 3,196.31 | 4.89 |
the information I want to store is I | 3,199.099 | 4.441 |
want to store data about what color you | 3,201.2 | 4.23 |
should change the text to when the | 3,203.54 | 3.45 |
button is clicked on and so what we're | 3,205.43 | 3.51 |
gonna have the ability to do now is the | 3,206.99 | 3.9 |
ability to say that if I have access to | 3,208.94 | 4.77 |
this element this button I can access | 3,210.89 | 6.09 |
its data color property to know whether | 3,213.71 | 5.28 |
we should change the text to red or blue | 3,216.98 | 4.32 |
or green by adding these data attributes | 3,218.99 | 4.39 |
to these HTML elements | 3,221.3 | 4.33 |
and so now what I want is some way of | 3,223.38 | 4.439 |
getting all of these buttons now | 3,225.63 | 5.31 |
document query selector as you recall | 3,227.819 | 6.181 |
just gets one element it's just going to | 3,230.94 | 4.919 |
get for me a single element and it's | 3,234 | 3.93 |
gonna get the first one that it finds if | 3,235.859 | 4.2 |
I want to get multiple elements what I | 3,237.93 | 3.899 |
can do instead is something like | 3,240.059 | 6.24 |
document dot query selector all query | 3,241.829 | 5.97 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.