All language subtitles for 147 Manipulating HTML Element Attributes.en_US

af Afrikaans
ak Akan
sq Albanian
am Amharic
ar Arabic Download
hy Armenian
az Azerbaijani
eu Basque
be Belarusian
bem Bemba
bn Bengali
bh Bihari
bs Bosnian
br Breton
bg Bulgarian
km Cambodian
ca Catalan
ceb Cebuano
chr Cherokee
ny Chichewa
zh-CN Chinese (Simplified)
zh-TW Chinese (Traditional)
co Corsican
hr Croatian
cs Czech
da Danish
nl Dutch
en English
eo Esperanto
et Estonian
ee Ewe
fo Faroese
tl Filipino
fi Finnish
fr French
fy Frisian
gaa Ga
gl Galician
ka Georgian
de German
el Greek
gn Guarani
gu Gujarati
ht Haitian Creole
ha Hausa
haw Hawaiian
iw Hebrew
hi Hindi
hmn Hmong
hu Hungarian
is Icelandic
ig Igbo
id Indonesian
ia Interlingua
ga Irish
it Italian
ja Japanese
jw Javanese
kn Kannada
kk Kazakh
rw Kinyarwanda
rn Kirundi
kg Kongo
ko Korean
kri Krio (Sierra Leone)
ku Kurdish
ckb Kurdish (Soranî)
ky Kyrgyz
lo Laothian
la Latin
lv Latvian
ln Lingala
lt Lithuanian
loz Lozi
lg Luganda
ach Luo
lb Luxembourgish
mk Macedonian
mg Malagasy
ms Malay
ml Malayalam
mt Maltese
mi Maori
mr Marathi
mfe Mauritian Creole
mo Moldavian
mn Mongolian
my Myanmar (Burmese)
sr-ME Montenegrin
ne Nepali
pcm Nigerian Pidgin
nso Northern Sotho
no Norwegian
nn Norwegian (Nynorsk)
oc Occitan
or Oriya
om Oromo
ps Pashto
fa Persian
pl Polish
pt-BR Portuguese (Brazil)
pt Portuguese (Portugal)
pa Punjabi
qu Quechua
ro Romanian
rm Romansh
nyn Runyakitara
ru Russian
sm Samoan
gd Scots Gaelic
sr Serbian
sh Serbo-Croatian
st Sesotho
tn Setswana
crs Seychellois Creole
sn Shona
sd Sindhi
si Sinhalese
sk Slovak
sl Slovenian
so Somali
es Spanish
es-419 Spanish (Latin American)
su Sundanese
sw Swahili
sv Swedish
tg Tajik
ta Tamil
tt Tatar
te Telugu
th Thai
ti Tigrinya
to Tonga
lua Tshiluba
tum Tumbuka
tr Turkish
tk Turkmen
tw Twi
ug Uighur
uk Ukrainian
ur Urdu
uz Uzbek
vi Vietnamese
cy Welsh
wo Wolof
xh Xhosa
yi Yiddish
yo Yoruba
zu Zulu

Original subtitles

So now that we've seen how you can manipulate the style and the text of an HTML element, the last thing

I want to show you how to manipulate are the attributes of any element.

So, just a reminder, the attributes are all the things that get colored in orange in Atom,

so for example, class is an attribute, or the href for an anchor tag is the attribute, or the src for

an image. They’re all attributes. Everything that goes inside the tag, other than the tag name itself, are attributes.

So we have a link up here that points towards Google,

right?

It takes us to the Google search page.

Now what if we've gone crazy and we decided to point people towards Bing instead?

Well, we can get a list of attributes that are attached to the element by saying document.querySelector

(“a”), and that of course gets us our first anchor tag which points towards Google.

And now if we say .attributes, then that will give us a list of all the attributes that are currently

attached to this HTML element.

And as you can see there's only one and that is the href.

So we can now retrieve the current value of that attribute by saying .getAttribute,

and notice how this is singular and not plural,

so we're only getting back the value of a single attribute, and we have to specify the name of the attribute

that we want.

So in this case it's the href, and you can see that we get back that currently it's pointing towards

google.com.

So now if we wanted to change this then instead of saying getAttribute, we can say setAttribute, but

this method takes two parameters, two inputs essentially.

One is which attribute do you want to change,

and the second one after the comma is what do you want to change it to,

and we're going to say www.bing.com.

Wow, I've never typed that in my life before.

All right. So now if I click on this link, even though it still says Google, because the innerHTML is Google,

if I click on it, you can see it takes me to this wonderful web site that nobody has ever used in their

lives before.

All right. Cool.

So this is a really quick and easy way of getting, setting, and seeing what the attributes are for any

element you select in the DOM.

Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.