Should I learn JQuery or JSON first
How to introduce jQuery for beginners. jQuery offers a lot - and that across browsers.
But more importantly, many possibilities can be implemented with just a few lines of jQuery code.
Use and possibilities of jQuery
Here are the possibilities in brief - later in detail
- Easy ways to select elements on the website (DOM) (to later do things like change appearance, animations or actions).
- Manipulate the DOM - i.e. change the selected elements accordingly (color, position, etc.)
- Event system: Depending on what the user is doing, you can simply react to it with jQuery. A mouse click and an area is displayed (and we are already at the next point)
- Animation and effects are extremely easy to implement. Extended texts, for example, can be gently faded in via a one-line liner, etc.
- Ajax is installed quickly and the bridge to the server is there. In other words, depending on the user action and user input, we can then fetch data from the server and continue working with it, e.g. show suggestions in a search field.
- Numerous plug-ins are available and an image gallery is built in in no time at all. So you don't have to keep reinventing the wheel.
So it's worth getting involved with and becoming friends with jQuery.
Integrate the jQuery library into your own website
Before we can use jQuery, we have to integrate the jQuery library into our website.
There are 2 ways to integrate jQuery. We can of course download all the necessary files from jQuery and make them available on our own web space (https://jquery.com) or simply set a link and then use jQuery.
Include locally (after downloading the files):
Or use the latest version from jquery.com:
JQuery can also be integrated via Google APIs (which makes 100% sense for learning when you are permanently online).
The required version of jQuery can also be specified here. Usually you will always use the latest.
If you don't want to use the above (i.e. jQuery version 1.10.2) you can get the current link the fastest at https://developers.google.com/speed/libraries/devguide?hl=de#jquery
The advantage of this approach is the speed aspect. If you integrate jQuery via Google and a visitor comes who has already visited another website that also uses jQuery via Google, the corresponding files are loaded directly from the cache.
3 advantages of loading jQuery via Google:
- jQuery may already be loaded because another website has integrated jQuery via Google. Thus, jQuery is already in the visitor's cache and immediately available.
- It loads faster from Google. It usually loads faster from the Google server because there is a limit to the number of files that can be loaded from a web server at the same time. So it is good if this file comes from another web server.
- Bandwidth is not used. If you don't have unlimited bandwidth, that can definitely be an issue.
Downside of loading jQuery through Google
The disadvantages should not be concealed.
- You have to be online all the time.
- If you are required for security reasons that no data go outside (e.g. company stories), then it may only come from your own server!
Include jQuery code
If we have now integrated the jquery.min.js, we can use jQuery. To do this, the desired jQuery code is integrated in thearea:
That would work - BUT, we only want to use jQuery when it is ensured that the website and all necessary resources are completely loaded. Otherwise it could happen that we want to change an element on the website that has not yet been fully loaded.
For this reason, the standard structure for jQuery is as follows:
Here you can already see the short form with the dollar sign. Actually, you could also write:
But shorter is more beautiful is faster. Therefore, in the wild, you will only see the shorthand spelling. But the long spelling makes the jQuery way of thinking clearer.
The complete source code in HTML5:
HOWEVER, the script TAGs must not be used in the external file, because according to the HTML file it is already one!
So the external file only says:
In thearea of our HTML file only the link needs to be made.
In the following jQuery tutorial, however, I will always work in thearea for the sake of clarity.
The following chapter is about the selection (the selection) of certain elements and how comfortably this is possible with jQuery.
- Increases productivity in coffee shops
- What is more important education or freedom
- Selena Gomez writes her own music
- Songs similar to Daft Punk's motherboard
- How do you overcome the fear of the first interview
- How often are restaurants thoroughly cleaned
- How is MAIT
- What is 6 9 x 2 3
- What does na raca mean in Portuguese?
- Vipasayana is healing from illness
- What were Dropbox's greatest technical achievements?
- How do I get nostalgia
- How to say everyone in French
- How does Google PhotoScan work
- What should everyone know about Montenegro
- What is a memorial hospital
- Is the Avogadros number exact
- What news did you really worry about today?
- What happened to the Indian auto industry
- How can you organize your life?
- How do I develop a firewall
- Which are deadly poisons
- Is Amazon Echo dot safe for children
- Has Niagara Falls ever frozen
- How was your first day of class
- What does neo mean in front of a word
- What are drains made of
- What is the most informative newspaper
- How do we pay mutual fund advisors
- Liverpool FC is a racist club
- What are the advantages of laser technology
- What is resident alien and non-resident alien
- Automotive mechanics What is the name of this part
- Why do some people not question anything