text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
selector all is going to return the same | 3,246.299 | 3.421 |
thing the query selector does but | 3,247.799 | 3.391 |
instead of query selector returning a | 3,249.72 | 3.089 |
single element that matches what it | 3,251.19 | 4.079 |
looks for query selector all is going to | 3,252.809 | 5.04 |
return to me an array of all of the | 3,255.269 | 4.651 |
elements that match my particular query | 3,257.849 | 4.051 |
so if I want to select not just the | 3,259.92 | 3.899 |
first button I find but all of the | 3,261.9 | 4.109 |
buttons I find I can here say query | 3,263.819 | 4.591 |
selector all for button and that will | 3,266.009 | 3.961 |
give me back a JavaScript array the | 3,268.41 | 4.08 |
equivalent of a list that represents all | 3,269.97 | 5.16 |
of those buttons and we can actually | 3,272.49 | 4.619 |
test what this looks like by looking at | 3,275.13 | 4.709 |
things inside of the JavaScript console | 3,277.109 | 6.091 |
that if I go ahead and refresh this page | 3,279.839 | 6.72 |
colors I can open up the inspector go | 3,283.2 | 5.25 |
into the JavaScript console and just as | 3,286.559 | 3.81 |
you could see error messages here you | 3,288.45 | 4.619 |
can also actually write JavaScript code | 3,290.369 | 5.611 |
here as well so I can say something like | 3,293.069 | 8.04 |
document query selector button say all | 3,295.98 | 7.26 |
right what's going to happen when I try | 3,301.109 | 3.93 |
and select for a button on this | 3,303.24 | 5.01 |
particular page and what I get is all | 3,305.039 | 5.01 |
right I get just this very first button | 3,308.25 | 4.529 |
button whose data - color is equal to | 3,310.049 | 4.23 |
red that's what I would expect query | 3,312.779 | 3.3 |
selector just finds me one element and | 3,314.279 | 2.941 |
it's going to find me | 3,316.079 | 4.2 |
the very first element and likewise I | 3,317.22 | 3.69 |
can say all right | 3,320.279 | 2.911 |
instead of query selector let's do query | 3,320.91 | 5.159 |
selector all and what I get back is a | 3,323.19 | 4.26 |
node list which you can think of as kind | 3,326.069 | 3.181 |
of like an array or a list in Python | 3,327.45 | 4.29 |
that's got three buttons in it button 0 | 3,329.25 | 5.759 |
1 and 2 and just as with a list in | 3,331.74 | 4.799 |
Python as you can index into things | 3,335.009 | 3.961 |
arrays and python arrays in JavaScript | 3,336.539 | 4.23 |
can be indexed into as well but if I | 3,338.97 | 3.66 |
have something like constant Eames | 3,340.769 | 7.05 |
equals Harry Ron and Hermione like a | 3,342.63 | 8.34 |
array of 3 names I can say name square | 3,347.819 | 5.49 |
bracket 0 to get the first name name | 3,350.97 | 3.869 |
square bracket 1 to get the second one | 3,353.309 | 3.51 |
name square bracket 2 to get the third | 3,354.839 | 2.401 |
one for | 3,356.819 | 2.221 |
example and that gives me each of the | 3,357.24 | 3.96 |
individual elements in the array if I | 3,359.04 | 3.24 |
want to get the whole length of the | 3,361.2 | 4.32 |
array I can do names dot lengths to get | 3,362.28 | 5.43 |
all right the length of the names array | 3,365.52 | 4.05 |
happens to be three so just some | 3,367.71 | 3.15 |
additional features that we have access | 3,369.57 | 3.27 |
to if you happen to have an array of | 3,370.86 | 2.82 |
things | 3,372.84 | 2.73 |
turns out query selector all returns to | 3,373.68 | 3.42 |
me a node list which is kind of like an | 3,375.57 | 3.63 |
array and that's going to be useful | 3,377.1 | 4.65 |
because when I say document query | 3,379.2 | 5.07 |
selector all button I am saying get me | 3,381.75 | 5.73 |
all of the buttons on the page and now | 3,384.27 | 5.13 |
what I would like to do is effectively | 3,387.48 | 5.25 |
loop over all of those buttons and say | 3,389.4 | 5.94 |
for each of the buttons inside of this | 3,392.73 | 4.65 |
list that comes back to me I would like | 3,395.34 | 4.56 |
to add an event handler for when that | 3,397.38 | 4.2 |
button is clicked on to say for each of | 3,399.9 | 3.6 |
the buttons that comes back go ahead and | 3,401.58 | 3.63 |
say when you're clicked on change the | 3,403.5 | 4.8 |
color of the h1 element and so there are | 3,405.21 | 4.8 |
a number of ways again that you could do | 3,408.3 | 5.55 |
this but one way is to use a particular | 3,410.01 | 7.41 |
property called for each and for each is | 3,413.85 | 6.09 |
a function that accepts as an argument | 3,417.42 | 5.189 |
another function where the idea is going | 3,419.94 | 5.04 |
to be I would like to run a function for | 3,422.609 | 5.101 |
each of the elements inside of an array | 3,424.98 | 5.82 |
or inside of a node list for example so | 3,427.71 | 6.84 |
here I can say for each button go ahead | 3,430.8 | 5.79 |
and run this function this is going to | 3,434.55 | 3.72 |
be a function now that takes something | 3,436.59 | 3.87 |
as input it's going to take one of the | 3,438.27 | 4.26 |
elements in the list as input something | 3,440.46 | 5.46 |
like a button and now for each button | 3,442.53 | 5.96 |
what would I like to do for that button | 3,445.92 | 5.43 |
well when the button is clicked on | 3,448.49 | 6.1 |
button dot on click then go ahead and | 3,451.35 | 9.269 |
run a function that is going to document | 3,454.59 | 9.72 |
query selector get me the element whose | 3,460.619 | 8.431 |
ID is hello change its style within the | 3,464.31 | 7.14 |
style change its color and what do I | 3,469.05 | 4.319 |
want to change its color to well I have | 3,471.45 | 3.78 |
access to this button this argument to | 3,473.369 | 3.961 |
the function is whichever button I'm | 3,475.23 | 3.36 |
currently trying to add an event | 3,477.33 | 3.84 |
listener for and in order to access its | 3,478.59 | 4.89 |
data properties I can access a special | 3,481.17 | 4.8 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.