News for hackers. Stuff that matters.
Re:Vue.js is easier to learn than jQuery by the_duke on Sunday October 30, 2016 @07:28AM (#12829220)
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>
Re:Vue.js is easier to learn than jQuery by kisstheblade on Sunday October 30, 2016 @08:35AM (#12829442)
Well 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.
Re:Vue.js is easier to learn than jQuery by wanda on Sunday October 30, 2016 @09:17AM (#12829613)
Probably 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.
Re:Vue.js is easier to learn than jQuery by LukasSkywalker on Sunday October 30, 2016 @09:17AM (#12829616)
You can always use document.querySelector() to target elements using a css selector
Re:Vue.js is easier to learn than jQuery by the_duke on Sunday October 30, 2016 @02:30PM (#12831405)
Whoops yeah, I just pasted from their jQuery code and forgot to remove the #. Remove them and it works: 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.