text stringlengths 1 81 | start float64 0 10.1k | duration float64 0 24.9 |
|---|---|---|
because Java Script allows us to | 775.63 | 4.23 |
manipulate the Dom the document object | 777.579 | 4.231 |
model that represents all of the | 779.86 | 4.28 |
elements that happen to be on that page | 781.81 | 5.339 |
so to do that let's go ahead and return | 784.14 | 6.91 |
to hello HTML this again was this paté | 787.149 | 6.031 |
web page that just said hello and gave | 791.05 | 3.69 |
me a button where if I clicked on that | 793.18 | 3.779 |
button it would display an alert that | 794.74 | 4.98 |
said hello world now what I'd like to do | 796.959 | 5.391 |
is instead of having the hello function | 799.72 | 5.309 |
display an alert I'd like to have it | 802.35 | 4.989 |
manipulate something on the page and | 805.029 | 4.291 |
what might I want me to manipulate well | 807.339 | 4.081 |
inside the body of the page I here have | 809.32 | 3.9 |
this heading this heading that just says | 811.42 | 4.26 |
hello for example which is inside of an | 813.22 | 4.65 |
h1 element and what I might like to do | 815.68 | 3.63 |
is actually change | 817.87 | 4.5 |
that element how can I do that well it | 819.31 | 4.86 |
turns out that in JavaScript we have | 822.37 | 4.71 |
access to a function called document dot | 824.17 | 6.42 |
query selector and what document query | 827.08 | 5.46 |
selector is going to do is it is going | 830.59 | 4.11 |
to give us the ability to look through | 832.54 | 5.37 |
an HTML page and extract an element out | 834.7 | 4.92 |
of that page so that we can manipulate | 837.91 | 4.95 |
that HTML element using JavaScript code | 839.62 | 5.88 |
and so if I want to select like an h1 | 842.86 | 4.979 |
element I can say document query | 845.5 | 4.5 |
selector and then as the argument the | 847.839 | 3.901 |
input to document our query selector | 850 | 4.68 |
I'll go ahead and say each one meaning | 851.74 | 5.94 |
go through the page find me an h1 | 854.68 | 4.62 |
element and query selector is only going | 857.68 | 3 |
to return one element so if they're | 859.3 | 2.61 |
multiple it's going to return the first | 860.68 | 3.33 |
thing it finds but here we only have one | 861.91 | 4.11 |
h1 element so it's ok I'm gonna say look | 864.01 | 4.8 |
through this document try and find in h1 | 866.02 | 5.13 |
element and when you do I'd like to | 868.81 | 4.08 |
manipulate it and the way I'd like to | 871.15 | 5.64 |
manipulate it is by saying dot innerhtml | 872.89 | 8.36 |
equals of let's say goodbye for example | 876.79 | 7.41 |
so alright what's going on here well | 881.25 | 4.75 |
right now initially when we first load | 884.2 | 3.99 |
the page we have an h1 a big heading at | 886 | 4.53 |
the top that just says hello and now | 888.19 | 4.29 |
when this hello function is called which | 890.53 | 3.54 |
is called when this button is clicked on | 892.48 | 3.12 |
because it has an on-click attribute | 894.07 | 3.93 |
that is equal to hello calling the hello | 895.6 | 4.41 |
function what the hello function is | 898 | 3.6 |
going to do is it's going to say | 900.01 | 4.829 |
document query selector h1 find me the | 901.6 | 6.78 |
h1 element that will return this element | 904.839 | 5.671 |
right here a JavaScript representation | 908.38 | 4.77 |
of this HTML element that is just an h1 | 910.51 | 5.85 |
whose HTML inside of it says hello and | 913.15 | 6.24 |
if I want to change that HTML I can do | 916.36 | 5.24 |
that by modifying the inner HTML | 919.39 | 5.64 |
property of the JavaScript elephant in | 921.6 | 5.29 |
order to update a property of anything | 925.03 | 3.72 |
in JavaScript will generally use this | 926.89 | 4.02 |
dot notation we're dot accesses of | 928.75 | 4.56 |
property of some particular object and | 930.91 | 4.619 |
so I have this element this h1 and | 933.31 | 5.04 |
saying dot inner HTML means take that | 935.529 | 4.741 |
element and access its inner HTML | 938.35 | 4.05 |
property some property of that object | 940.27 | 4.259 |
and I would like to update its inner | 942.4 | 4.83 |
HTML to just in this case be the word | 944.529 | 4.741 |
goodbye followed by an exclamation point | 947.23 | 3.32 |
for example | 949.27 | 3.8 |
so now what we'll see is that when we | 950.55 | 4.95 |
run this page when we open this page up | 953.07 | 6.36 |
as by opening up hello HTML I still see | 955.5 | 5.73 |
an h1 that says hello I still see a | 959.43 | 4.86 |
button that says click here but now when | 961.23 | 4.62 |
I actually click on the button click | 964.29 | 4.229 |
here you'll see that hello changes to | 965.85 | 3.179 |
goodbye | 968.519 | 3.031 |
we've run JavaScript code that finds an | 969.029 | 4.56 |
h1 element on the page and manipulates | 971.55 | 4.32 |
it changing it to something else than it | 973.589 | 4.411 |
was originally now every time I click | 975.87 | 4.68 |
here nothing else happens because every | 978 | 4.35 |
time I click here it's going to find the | 980.55 | 3.96 |
same h1 and it's going to update its | 982.35 | 5.07 |
HTML changing it from hello to goodbye | 984.51 | 5.16 |
so maybe what I'd really like then is | 987.42 | 4.77 |
the ability to toggle back and forth to | 989.67 | 4.349 |
toggle back and forth between hello and | 992.19 | 3.209 |
goodbye rather than just change it from | 994.019 | 3.661 |
one thing to something else every time I | 995.399 | 3.331 |
click the button I'd like it to | 997.68 | 3.3 |
alternate back and forth and there are a | 998.73 | 3.479 |
number of ways you can imagine doing | 1,000.98 | 3.299 |
this but one way is by taking advantage | 1,002.209 | 4.081 |
of conditions so much in the same way | 1,004.279 | 3.541 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.