What is jQuery?
It is designed to be compatible across browsers and allows for DOM (document object model) traversal and event handling. As far as I understand it, this is where you can pick out elements in a HTML document and either make changes to them or create a response based on an action – such as a button click.
It is also designed to be able to easily implement Ajax into your web page which allows the sending and receiving of data from the server in the background. This is great as it means you don’t have to physically reload everything on your web page, if all that you want to change is a small portion of your site.
Below is an example of changing some text from the classic “Hello World” to “Hello Lucy” when you click on an HTML button within a web page.
<p id="text"> Hello World! </p> <button id=”myButton”>Click to change text</button>
and in jQuery:
As you can see, the jQuery version is a lot simpler and due to the small size of the jQuery library, it will be executed very quickly too.
Why should you use jQuery?
As you can see jQuery is a much shorter way to access HTML elements in your page which across large websites with multiple pages and scripts can cut down on a lot of unnecessary code. This makes it easier to read, quicker to write and a lot neater too – great if you are collaborating with others. jQuery has been around for a while (compared to other libraries) and is well supported by most browsers as well as being compatible with CSS3 selectors. It also loads nice and quickly, as more often than not you will only need to use a minimized version of the file, which is great for website performance.
There are also a lot of open source plugins available to further widen the range of things you can achieve with jQuery libraries.
Is jQuery dead?
I myself am not quite there yet as I still have many of the basics to learn, but all in good time!
Useful resources if you wish to learn or use jQuery
These websites are connected and have an absolute wealth of information. If you are really interested there is enough content on there to last you a good few hours. There are also lots of opportunities to try out the code for yourself, without having to know much or have built something beforehand.
A really great way to get a basic overview and introduction. I found this to be one of the best ways to get hands on and start coding straight away. I believe they are actually removing this course soon and replacing it with something new, so keep your eyes peeled for that.
A great Udemy course that is not only free but also covers the basics along with explanations as to why you may find it useful.
- jQuery Pocket Reference – David Flanagan
- jQuery For Beginners – iCode Academy
- AngularJS: Up and Running – Shyam Seshadri
- Learning AngularJS – Ken Williamson
- React.js Book – Greg Sidelnikov
*some affiliate links used