Learning how to program can be a bit intimidating at first, but no worries I've found an amazing tool that can inspire you to dig deeper into programming. That tool is j Query! A JavaScript library or framework designed to make manipulating the DOM easier and solve browser compatibility problems.
Getting Started
Start up your code editor and in your html file put a script tag inside your head tag. In the script tag you will link your src to a local file or a CDN (Content Delivery Network). For further instructions check the j Query download page https://jquery.com/download/
Selecting Elements
You can select any element in the DOM using $("value"). In this example i'm doing something very simple by just changing the header but only for you to understand the syntax. I follow up with .text("") method to change the text to "King of the Jungle"! You can select by specifying the $("element") , $(".className") , or $("#idName").
Styling
The way you style with j Query is by using the .css() method.The first argument will be the name of the property and the second a value. This can be very effective in manipulating multiple things at once or even just one element at a time without the use of writing loops in JavaScript.
Events
The .on() method is a popular method that will carry out code based on the specified event. Since we want a li to change color if it gets clicked. We must use the keyword this, which refers to the specific li that was clicked. If we were to use Vanilla JavaScript (JavaScript without j Query) there would be more code to carry out this event. This is more understandable, concise, and easy to write.
Conclusion
It is a great debate if new comers should learn j Query. Developers say it's easy to write spaghetti code because of it's simplicity. It was made to solve browser compatibility problems in 2006 but we don't have those problems anymore. Although, Uber, Twitter , Reddit and many more companies still use j Query.I suggest to learn j Query especially if you want to be on the front end.Then when you get a better understanding of things learn some JavaScript to have more control of your code.Even take a look into j Query's cousins React and Angular. There are many resources and YouTube videos that can help you. Why not learn something new? Happy Coding. Thanks for reading!
Top comments (0)