3 ms·
The assumption this article makes is that beginners don't know the DOM and browser APIs, so if they don't, vue.js is easier than jQuery. That's kind of ridicul
by the_duke 10y ago
The assumption this article makes is that beginners don't know the DOM and browser APIs, so if they don't, vue.js is easier than jQuery.
That's kind of ridiculous though.
No one should be writing anything for the web without a basic understanding of how the DOM works, even if you wrap things like jQuery, vue.js or React around it.
It's not that complicated.
Every beginners tutorial should start with a basic introduction to the DOM, with some examples, and without ANY libraries.
Using jQuery here is pointless.
Here, without jQuery. How is using jQuery here with a beginner of ANY help?
<html>
<body>
<div id="output">0</div>
<button id="increment">Increment</button>
<script>
var counter = 0;
var output = document.getElementById('#output');
document.getElementById('#increment').onclick = function() {
counter += 1;
output.innerHTML = counter;
};
</script>
</body>
</html>
- kisstheblade 10y agoWell if they come from a web design background they know the css selectors which work with jquery. Unlike your example, which doesn't work as written.
- wanda 10y agoProbably doesn't work because document.getElementById doesn't work with a CSS #id selector as a parameter, it needs the bare id, so it isn't finding the increment or output elements.
- LukasSkywalker 10y agoYou can always use document.querySelector() to target elements using a css selector
- the_duke 10y agoWhoops yeah, I just pasted from their jQuery code and forgot to remove the #. Remove them and it works: https://jsfiddle.net/wqxxufkv/ https://jsfiddle.net/wqxxufkv/ But as Skywalker mentioned, node.querySelector() / querySelectorAll has been working well across browsers for a while and supports most expressions jQuery selectors would.