document.getElementById and jQuery ID selector are not equivalent.
var element = document.getElementById('id');
returns an HTML DOM Object, and
var element = $('#id');
returns a jQuery Object. In jQuery, to get the same result as document.getElementById we can do:
var element = $('#id')[0];
Top comments (3)
You can do this in a few different ways in YumJS too.
One of the easiest is getting the first of a class:
Aside from a the familiar chainable syntax, YumJS is very different than JQuery.
It doesn't replicate all of JQuery's functions but it does do other things that JQuery doesn't do with regard to reactivity and an optional component style syntax both of which can be mixed!
YumJS is also super small too. So...if you are still using JQuery give YumJS a try.
Check out my introductory article here on Dev.to dev.to/bretgeek/introducing-yumjs-...
We don't need jQuery any more.
If you add an id to something, js creates an accessible variable with the same name, thats why yo shouldnt add the same id to multiple elements.