I’m just starting with JQuery and am working through a tutorial vid. At one point the presenters go for javascript instead of a JQuery selector. Just wondering why the javascript getElementById below works fine when passing an object to a function, but the second one doesn’t?
Thanks!
// works
addTask(document.getElementById('taskText'), evt);
// doesn't
addTask($('#taskText'), evt);
getElementById()returns a DOM element reference.jQuery’s selector returns a jQuery object. You can get the element reference from the jQuery object using
See http://api.jquery.com/get/