Afrikaans
Akan
Albanian
Amharic
Armenian
Azerbaijani
Basque
Belarusian
Bemba
Bengali
Bihari
Bosnian
Breton
Bulgarian
Cambodian
Catalan
Cebuano
Cherokee
Chichewa
Chinese (Simplified)
Chinese (Traditional)
Corsican
Croatian
Czech
Danish
Dutch
English
Esperanto
Estonian
Ewe
Faroese
Filipino
Finnish
French
Frisian
Ga
Galician
Georgian
German
Greek
Guarani
Gujarati
Haitian Creole
Hausa
Hawaiian
Hebrew
Hindi
Hmong
Hungarian
Icelandic
Igbo
Indonesian
Interlingua
Irish
Italian
Japanese
Javanese
Kannada
Kazakh
Kinyarwanda
Kirundi
Kongo
Korean
Krio (Sierra Leone)
Kurdish
Kurdish (Soranî)
Kyrgyz
Laothian
Latin
Latvian
Lingala
Lithuanian
Lozi
Luganda
Luo
Luxembourgish
Macedonian
Malagasy
Malay
Malayalam
Maltese
Maori
Marathi
Mauritian Creole
Moldavian
Mongolian
Myanmar (Burmese)
Montenegrin
Nepali
Nigerian Pidgin
Northern Sotho
Norwegian
Norwegian (Nynorsk)
Occitan
Oriya
Oromo
Pashto
Persian
Polish
Portuguese (Brazil)
Portuguese (Portugal)
Punjabi
Quechua
Romanian
Romansh
Runyakitara
Russian
Samoan
Scots Gaelic
Serbian
Serbo-Croatian
Sesotho
Setswana
Seychellois Creole
Shona
Sindhi
Sinhalese
Slovak
Slovenian
Somali
Spanish
Spanish (Latin American)
Sundanese
Swahili
Swedish
Tajik
Tamil
Tatar
Telugu
Thai
Tigrinya
Tonga
Tshiluba
Tumbuka
Turkish
Turkmen
Twi
Uighur
Ukrainian
Urdu
Uzbek
Vietnamese
Welsh
Wolof
Xhosa
Yiddish
Yoruba
Zulu
Now in order to change the text of a selected element using JQuery, there's two ways of going about
this.
One is you can simply, say, select an element, then .text, and inside the parentheses you'll add the
new text that you want it to say,
so this will change our hello to a goodbye.
As we mentioned before, when we use jQuery to select an HTML element, it selects all of the elements
that match that selector on your web page.
So if we were to say .text on the buttons, then when we refresh our page, you can see that every single
button gets its text updated by simply selecting for all the elements that match this criteria,
and then we're using the .text method to change the text that's inside those buttons, which is this
part here.
Now, if you remember, when we learnt how to do this using plain old vanilla Javascript, we also had something
called innerHTML. And using innerHTML,
we were able to not just update text but we were also able to add HTML. But, as we’re using jQuery, it's
a little bit shorter.
So it's simply .html. And inside here we can add some tags, say for example if we wanted to add the
em tag to make our text emphasized, or rather italicised.
Now when we update our web site you can see that the HTML is also taken into consideration, because we're
using the .html method instead of simply the .text method which will interpret everything in between
the quotation marks as pure text and ignores all of the HTML tags.
Now by this point you would have noticed that most of the things that you do with jQuery are implemented
using methods, and we’re accessing it through the dot notation.
Now remember how, when we were learning about methods and functions,
we used it a lot to shorten our code and reduce repetition.
Well this is pretty much how jQuery works.
If you take a look at the library then you'll notice that jQuery is completely written in Javascript,
but it has all of these methods that shorten the code that we need to write and makes working with Javascript
to create our web sites much much quicker, much easier, and reduces repetitive strain injury from typing
so much.
So I hope that you also realize that without understanding how vanilla Javascript works, then jQuery
just seems like complete magic.
So it's really important that you needed to get a good foundation in Javascript before we started introducing
you to essentially what most web developers will use when they're writing Javascript, which is doing
it through jQuery or another library.
I hope that by this point you've already realized that this library can make your life as a developer
so much easier with less things to type and more intuitive syntax.
But in the next lesson we're going to dig into jQuery even further and we're going to learn how
we can manipulate attributes using jQuery.
So for all of that, stay tuned.
I'll see you on the next lesson.
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.