I use jQuery at the moment because I use it for a lot of years already, but now Bootstrap 5 decided to switch to JavaScript, I am thinking of switching to an alternative.
I use jQuery only for the DOM integration, animations and ajax calls because JavaScript calls to a class looks such a long call. I like the way of jQuery with $(document).on('click','.something',function() {});
By the way, I like to keep using HTML, PHP and Bootstrap as I do now.
I was like you two years ago, used to jquery and didn't want to switch, but if you're willing to use js frameworks in your projects(React, Vuejs...), I advise you to switch asap, and get used to normal javascript, because in the end, it's the core language, but there are some new ways in it (especially in ES6) that will make your life easier, like you can replace the document.querySelector()
with $()
and document.querySelectorAll()
with $$()
, using this line of code:
const $ = e => document.querySelector(e), $$ = e => document.querySelectorAll(e);
then you can select a p element just by writing: $('p')
, and multiple p elements like that: $$('p')
.
I hope my advice helped you in any way.
Um, those jQuery-like calls like`$()` and `$$()` work ONLY in the dev tools console. You cannot incorporate them into the scripts that your browser itself runs. If you try that, you'll get a ReferenceError because `$` is not a defined variable.
They are handy when poking around in the DOM by hand in the console, though.
Hi Adan,
Javascript has changed quite a bit in the recent years and lot of it was inspired from jquery. Now almost all modern browsers support javascript syntax everything that jquery does with few elaborate / sometimes better alternatives. So, if you like to switch, find the equivalents of what portions of jquery you use and replace those parts. Btw, jquery is still nicer sometimes with its method chaining and a lot simpler syntax - the equivalent in js may not be that sugary syntactically.
Thank you for the explanation and i think ill switch to plain JS.